MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / PurgeLFU

Method PurgeLFU

internal/caches/list_file_sqlite.go:294–329  ·  view source on GitHub ↗
(count int, callback func(hash string) error)

Source from the content-addressed store, hash-verified

292}
293
294func (this *SQLiteFileList) PurgeLFU(count int, callback func(hash string) error) error {
295 count /= CountFileDB
296 if count <= 0 {
297 count = 100
298 }
299
300 for _, db := range this.dbList {
301 hashStrings, err := db.ListLFUItems(count)
302 if err != nil {
303 return err
304 }
305
306 if len(hashStrings) == 0 {
307 continue
308 }
309
310 // 不在 rows.Next() 循环中操作是为了避免死锁
311 for _, hash := range hashStrings {
312 _, err = this.remove(hash, true)
313 if err != nil {
314 return err
315 }
316
317 err = callback(hash)
318 if err != nil {
319 return err
320 }
321 }
322
323 _, err = db.writeDB.Exec(`DELETE FROM "cacheItems" WHERE "hash" IN ('` + strings.Join(hashStrings, "', '") + `')`)
324 if err != nil {
325 return err
326 }
327 }
328 return nil
329}
330
331func (this *SQLiteFileList) CleanAll() error {
332 defer this.memoryCache.Clean()

Callers

nothing calls this directly

Calls 3

removeMethod · 0.95
ListLFUItemsMethod · 0.80
ExecMethod · 0.45

Tested by

no test coverage detected