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

Method ListLFUItems

internal/caches/list_file_db_sqlite.go:256–282  ·  view source on GitHub ↗
(count int)

Source from the content-addressed store, hash-verified

254}
255
256func (this *SQLiteFileListDB) ListLFUItems(count int) (hashList []string, err error) {
257 if !this.isReady {
258 return nil, nil
259 }
260
261 if count <= 0 {
262 count = 100
263 }
264
265 // 先找过期的
266 hashList, err = this.ListExpiredItems(count)
267 if err != nil {
268 return
269 }
270 var l = len(hashList)
271
272 // 从旧缓存中补充
273 if l < count {
274 oldHashList, err := this.listOlderItems(count - l)
275 if err != nil {
276 return nil, err
277 }
278 hashList = append(hashList, oldHashList...)
279 }
280
281 return hashList, nil
282}
283
284func (this *SQLiteFileListDB) ListHashes(lastId int64) (hashList []string, maxId int64, err error) {
285 rows, err := this.selectHashListStmt.Query(lastId)

Callers 3

TestFileListDB_MemoryFunction · 0.80
PurgeLFUMethod · 0.80

Calls 2

ListExpiredItemsMethod · 0.95
listOlderItemsMethod · 0.95

Tested by 2

TestFileListDB_MemoryFunction · 0.64