MCPcopy Index your code
hub / github.com/coder/coder / purge

Method purge

coderd/files/cache.go:261–279  ·  view source on GitHub ↗

purge immediately removes an entry from the cache, even if it has open references. Safety: Must only be called while the Cache lock is held

(fileID uuid.UUID)

Source from the content-addressed store, hash-verified

259// references.
260// Safety: Must only be called while the Cache lock is held
261func (c *Cache) purge(fileID uuid.UUID) {
262 entry, ok := c.data[fileID]
263 if !ok {
264 // If we land here, it's probably because of a fetch attempt that
265 // resulted in an error, and got purged already. It may also be an
266 // erroneous extra close, but we can't really distinguish between those
267 // two cases currently.
268 return
269 }
270
271 // Purge the file from the cache.
272 c.currentOpenFiles.Dec()
273 ev, err := entry.value.Load()
274 if err == nil {
275 c.currentCacheSize.Add(-1 * float64(ev.Size))
276 }
277
278 delete(c.data, fileID)
279}
280
281// Count returns the number of files currently in the cache.
282// Mainly used for unit testing assertions.

Callers 2

prepareMethod · 0.95
AcquireMethod · 0.80

Calls 2

AddMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected