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

Method CleanPrefix

internal/caches/list_file_db_sqlite.go:310–329  ·  view source on GitHub ↗
(prefix string)

Source from the content-addressed store, hash-verified

308}
309
310func (this *SQLiteFileListDB) CleanPrefix(prefix string) error {
311 if !this.isReady {
312 return nil
313 }
314 var count = int64(10000)
315 var unixTime = fasttime.Now().Unix() // 只删除当前的,不删除新的
316 for {
317 result, err := this.writeDB.Exec(`UPDATE "`+this.itemsTableName+`" SET expiredAt=0,staleAt=? WHERE id IN (SELECT id FROM "`+this.itemsTableName+`" WHERE expiredAt>0 AND createdAt<=? AND INSTR("key", ?)=1 LIMIT `+types.String(count)+`)`, unixTime+DefaultStaleCacheSeconds, unixTime, prefix)
318 if err != nil {
319 return this.WrapError(err)
320 }
321 affectedRows, err := result.RowsAffected()
322 if err != nil {
323 return err
324 }
325 if affectedRows < count {
326 return nil
327 }
328 }
329}
330
331func (this *SQLiteFileListDB) CleanMatchKey(key string) error {
332 if !this.isReady {

Callers

nothing calls this directly

Calls 5

WrapErrorMethod · 0.95
NowFunction · 0.92
UnixMethod · 0.80
ExecMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected