MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / cleaner

Method cleaner

cache/filesystem_cache.go:200–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198}
199
200func (f *fileSystemCache) cleaner() {
201 d := f.expire / 2
202 if d < time.Minute {
203 d = time.Minute
204 }
205 if d > time.Hour {
206 d = time.Hour
207 }
208 forceCleanCh := time.After(d)
209
210 f.clean()
211 for {
212 select {
213 case <-time.After(time.Second):
214 // Clean cache only on cache size overflow.
215 stats := f.Stats()
216 if stats.Size > f.maxSize {
217 f.clean()
218 }
219 case <-forceCleanCh:
220 // Forcibly clean cache from expired items.
221 f.clean()
222 forceCleanCh = time.After(d)
223 case <-f.stopCh:
224 return
225 }
226 }
227}
228
229func (f *fileSystemCache) fileInfoPath(fi os.FileInfo) string {
230 return filepath.Join(f.dir, fi.Name())

Callers 1

newFilesSystemCacheFunction · 0.95

Calls 2

cleanMethod · 0.95
StatsMethod · 0.95

Tested by

no test coverage detected