 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  
var ErrCacheRecursiveCall = fmt.Errorf("recursive call detected")
    Functions ¶
func CurrentStorageKey ¶ added in v0.19.4
Get the key that should be used (or mixed into) persistent cache storage We smuggle this around in the context for now since we have to incorporate it with buildkit's persistent cache for now.
Types ¶
type Cache ¶ added in v0.16.3
type Cache[K KeyType, V any] interface { // Using the given key, either return an already cached value for that key or initialize // an entry in the cache with the given value for that key. GetOrInitializeValue(context.Context, CacheKey[K], V) (Result[K, V], error) // Using the given key, either return an already cached value for that key or initialize a // new value using the given function. If the function returns an error, the error is returned. GetOrInitialize( context.Context, CacheKey[K], func(context.Context) (V, error), ) (Result[K, V], error) // Using the given key, either return an already cached value for that key or initialize a // new value using the given function. If the function returns an error, the error is returned. // The function returns a ValueWithCallbacks struct that contains the value and optionally // any additional callbacks for various parts of the cache lifecycle. GetOrInitializeWithCallbacks( context.Context, CacheKey[K], func(context.Context) (*ValueWithCallbacks[V], error), ) (Result[K, V], error) // Returns the number of entries in the cache. Size() int // Run a blocking loop that periodically garbage collects expired entries from the cache db. GCLoop(context.Context) }
type CacheKey ¶
type CacheKey[K KeyType] struct { // CallKey is identifies the the call. If a call has already been completed with this // CallKey and it is not expired, its cached result will be returned. CallKey K // ConcurrencyKey is used to determine whether *in-progress* calls should be deduplicated. // If a call with a given (ResultKey, ConcurrencyKey) pair is already in progress, and // another one comes in with the same pair, the second caller will wait for the first // to complete and receive the same result. // // If two calls have the same ResultKey but different ConcurrencyKeys, they will not be deduped. // // If ConcurrencyKey is the zero value for K, no deduplication of in-progress calls will be done. ConcurrencyKey K // TTL is the time-to-live for the cached result of this call, in seconds. TTL int64 // DoNotCache indicates that this call should not be cached at all, simply ran. DoNotCache bool }
type OnReleaseFunc ¶ added in v0.16.3
type PostCallFunc ¶ added in v0.16.3
type ValueWithCallbacks ¶ added in v0.16.3
type ValueWithCallbacks[V any] struct { // The actual value to cache Value V // If set, a function that should be called whenever the value is returned from the cache (whether newly initialized or not) PostCall PostCallFunc // If set, this function will be called when a result is removed from the cache OnRelease OnReleaseFunc // If true, indicates that it is safe to persist this value in the cache db (i.e. does not have // any in-memory only data). SafeToPersistCache bool }
 Click to show internal directories. 
   Click to hide internal directories.