Modules/businessdev.ALbuild.Containers/Private/Get-BcImageUsageMarkerPath.ps1

function Get-BcImageUsageMarkerPath {
    <#
    .SYNOPSIS
        Path of the "last used" marker file for a cached Business Central image.
 
    .DESCRIPTION
        Docker knows when an image was created, not when it was last used - and for this cache those are
        very different things. An image is built once and then reused for months, so evicting by age
        would throw out exactly the platform versions being asked for most.
 
        One file per image, rather than a shared index: touching a file is atomic enough for a timestamp,
        whereas a shared JSON index would need a read-modify-write lock on a path that several workers
        hit simultaneously - added coordination for no benefit.
 
        The file name is a hash, not the tag: tags contain ':' and are not valid file names on Windows.
 
    .PARAMETER ImageName
        The image tag.
 
    .OUTPUTS
        System.String
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $ImageName
    )

    $root = Join-Path (Get-ALbuildConfig -Name 'BaseFolder') 'bcimages'
    $sha = [System.Security.Cryptography.SHA256]::Create()
    try { $bytes = $sha.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($ImageName.ToLowerInvariant())) }
    finally { $sha.Dispose() }
    $hash = [System.BitConverter]::ToString($bytes).Replace('-', '').Substring(0, 16)
    return (Join-Path $root "$hash.lastused")
}