MCPcopy
hub / github.com/perkeep/perkeep / NewCache

Function NewCache

pkg/blobserver/memory/mem.go:74–79  ·  view source on GitHub ↗

NewCache returns a cache that won't store more than size bytes. Blobs are evicted in LRU order.

(size int64)

Source from the content-addressed store, hash-verified

72// NewCache returns a cache that won't store more than size bytes.
73// Blobs are evicted in LRU order.
74func NewCache(size int64) *Storage {
75 return &Storage{
76 maxSize: size,
77 lru: lru.New(0), // infinite items; we evict by size, not count
78 }
79}
80
81func (s *Storage) Fetch(ctx context.Context, ref blob.Ref) (file io.ReadCloser, size uint32, err error) {
82 s.mu.RLock()

Callers 6

newFromConfigFunction · 0.92
TestCacheFunction · 0.92
newFromConfigFunction · 0.92
NewProxiedDiskFunction · 0.92
TestProxyCacheFunction · 0.92

Calls 1

NewFunction · 0.92

Tested by 3

TestCacheFunction · 0.74
NewProxiedDiskFunction · 0.74
TestProxyCacheFunction · 0.74