MCPcopy
hub / github.com/perkeep/perkeep / removeOldest

Method removeOldest

pkg/blobserver/proxycache/proxycache.go:110–130  ·  view source on GitHub ↗

must hold sto.mu. Reports whether an item was removed.

()

Source from the content-addressed store, hash-verified

108// must hold sto.mu.
109// Reports whether an item was removed.
110func (sto *Storage) removeOldest() bool {
111 ctx := context.TODO()
112 k, v := sto.lru.RemoveOldest()
113 if v == nil {
114 return false
115 }
116 sb := v.(blob.SizedRef)
117 // TODO: run these without sto.mu held in background
118 // goroutine? at least pass a context?
119 err := sto.cache.RemoveBlobs(ctx, []blob.Ref{sb.Ref})
120 if err != nil {
121 log.Printf("proxycache: could not remove oldest blob %v (%d bytes): %v", sb.Ref, sb.Size, err)
122 sto.lru.Add(k, v)
123 return false
124 }
125 if sto.debug {
126 log.Printf("proxycache: removed blob %v (%d bytes)", sb.Ref, sb.Size)
127 }
128 sto.cacheBytes -= int64(sb.Size)
129 return true
130}
131
132func (sto *Storage) touch(sb blob.SizedRef) {
133 key := sb.Ref.String()

Callers 1

touchMethod · 0.95

Calls 4

RemoveOldestMethod · 0.80
PrintfMethod · 0.80
RemoveBlobsMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected