Documentation
¶
Index ¶
- Constants
- type Cache
- type CacheConfig
- type EvictCallback
- type Option
- func WithAccessLogger(logger *log.Logger) Option
- func WithEndpointMetrics() Option
- func WithMaxBlobSize(size int64) Option
- func WithMaxSizeHardLimit(maxSizeHardLimit int64) Option
- func WithProxyBackend(proxy cache.Proxy) Option
- func WithProxyMaxBlobSize(maxProxyBlobSize int64) Option
- func WithStorageMode(mode string) Option
- func WithZstdImplementation(impl string) Option
- type SizedLRU
- func (c *SizedLRU) Add(key string, value lruItem) (ok bool)
- func (c *SizedLRU) Get(key string) (lruItem, *list.Element)
- func (c *SizedLRU) Len() int
- func (c *SizedLRU) MaxSize() int64
- func (c *SizedLRU) RegisterMetrics()
- func (c *SizedLRU) RemoveElement(elem *list.Element)
- func (c *SizedLRU) RemoveKey(key string)
- func (c *SizedLRU) Reserve(size int64) error
- func (c *SizedLRU) ReservedSize() int64
- func (c *SizedLRU) TotalSize() int64
- func (c *SizedLRU) UncompressedSize() int64
- func (c *SizedLRU) Unreserve(size int64) error
Constants ¶
const BlockSize = 4096
Actual disk usage will be estimated by rounding file sizes up to the nearest multiple of this number.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, kind cache.EntryKind, hash string, size int64, offset int64) (io.ReadCloser, int64, error)
GetValidatedActionResult(ctx context.Context, hash string) (*pb.ActionResult, []byte, error)
GetZstd(ctx context.Context, hash string, size int64, offset int64) (io.ReadCloser, int64, error)
Put(ctx context.Context, kind cache.EntryKind, hash string, size int64, r io.Reader) error
Contains(ctx context.Context, kind cache.EntryKind, hash string, size int64) (bool, int64)
FindMissingCasBlobs(ctx context.Context, blobs []*pb.Digest) ([]*pb.Digest, error)
MaxSize() int64
Stats() (totalSize int64, reservedSize int64, numItems int, uncompressedSize int64)
RegisterMetrics()
}
type CacheConfig ¶
type CacheConfig struct {
// contains filtered or unexported fields
}
type EvictCallback ¶
type EvictCallback func(key string, value lruItem)
EvictCallback is the type of callbacks that are invoked when items are evicted.
type Option ¶
type Option func(*CacheConfig) error
func WithAccessLogger ¶
func WithEndpointMetrics ¶
func WithEndpointMetrics() Option
func WithMaxBlobSize ¶
func WithMaxSizeHardLimit ¶ added in v2.6.0
func WithProxyBackend ¶
func WithProxyMaxBlobSize ¶
func WithStorageMode ¶
func WithZstdImplementation ¶
type SizedLRU ¶
type SizedLRU struct {
// contains filtered or unexported fields
}
SizedLRU is an LRU cache that will keep its total size below maxSize by evicting items. SizedLRU is not thread-safe.
func NewSizedLRU ¶
func NewSizedLRU(maxSize int64, onEvict EvictCallback, initialCapacity int) SizedLRU
NewSizedLRU returns a new SizedLRU cache
func (*SizedLRU) Add ¶
Add adds a (key, value) to the cache, evicting items as necessary. Add returns false and does not add the item if the item size is larger than the maximum size of the cache, or if the item cannot be added to the cache because too much space is reserved.
Note that this function rounds file sizes up to the nearest BlockSize (4096) bytes, as an estimate of actual disk usage since most linux filesystems default to 4kb blocks.
func (*SizedLRU) Get ¶
Get looks up a key in the cache. The lruItem is only valid if *list.Element is not nil.
func (*SizedLRU) RegisterMetrics ¶
func (c *SizedLRU) RegisterMetrics()
func (*SizedLRU) RemoveElement ¶ added in v2.6.1
Remove a *list.Element from the cache.