type Cache struct {
// contains filtered or unexported fields
}
Cache persists the files for template versions, and is used by dynamic
parameters to deduplicate the files in memory. When any number of users opens
the workspace creation form for a given template version, it's files are
loaded into memory exactly once. We hold those files until there are no
longer any open connections, and then we remove the value from the map.
Acquire will load the fs.FS for the given file. It guarantees that parallel
calls for the same fileID will only result in one fetch, and that parallel
calls for distinct fileIDs will fetch in parallel.
Safety: Every call to Acquire that does not return an error must call close
on the returned value when it is done being used.
type CloseFS struct {
fs.FS// contains filtered or unexported fields
}
CloseFS is a wrapper around fs.FS that implements io.Closer. The Close()
method tells the cache to release the fileID. Once all open references are
closed, the file is removed from the cache.