cache

package
v0.0.0-...-2dffccf Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 22 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 {
	Root string // the root cache directory
}

Cache represents an on-disk cache of unpacked tarballs.

It also knows how to populate and trim it.

Directory layout:

<Root>/
  <artifact's sha256 hex digest>/
    lock           # lock file to manage concurrent access
    cache.json     # bookkeeping info about this cache entry
    tmp_*.tar.gz   # exists temporarily when fetching the tarball
    tmp_data_*/    # exists temporarily when unpacking the tarball
    data/          # the unpacked tarball goes here

func (*Cache) Trim

func (c *Cache) Trim(ctx context.Context, keep int) error

Trim removes old cache entries, keeping only most recently touched ones.

func (*Cache) WithTarball

func (c *Cache) WithTarball(ctx context.Context, src source.Source, cb func(path string) error) error

WithTarball calls `cb` with a path to the unpacked tarball.

If the cache has such tarball already (as identified by its SHA256 digest), calls `cb` right away. Otherwise fetches and unpacks the tarball first.

`cb` may modify files in the directory if necessary. Modifications will be preserved in the cache, and multiple concurrent WithTarballs calls (perhaps made from different processes) will see each other's modifications, so `cb` should be careful doing them. This is required to allow gaedeploy to generate temporary app-specific GAE YAMLs, which are required by gcloud to be side-by-side with the code being deployed (and thus must reside inside the unpacked tarball directory).

Jump to

Keyboard shortcuts

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