NewCache returns a cache that won't store more than size bytes. Blobs are evicted in LRU order.
(size int64)
| 72 | // NewCache returns a cache that won't store more than size bytes. |
| 73 | // Blobs are evicted in LRU order. |
| 74 | func 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 | |
| 81 | func (s *Storage) Fetch(ctx context.Context, ref blob.Ref) (file io.ReadCloser, size uint32, err error) { |
| 82 | s.mu.RLock() |