files

package
v2.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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.

func NewFromStore

func NewFromStore(store database.Store) Cache

NewFromStore returns a file cache that will fetch files from the provided database.

func (*Cache) Acquire

func (c *Cache) Acquire(ctx context.Context, fileID uuid.UUID) (fs.FS, error)

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.

Every call to Acquire must have a matching call to Release.

func (*Cache) Release

func (c *Cache) Release(fileID uuid.UUID)

Release decrements the reference count for the given fileID, and frees the backing data if there are no further references being held.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL