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

Method Load

internal/caches/list_file_hash_map_sqlite.go:47–76  ·  view source on GitHub ↗
(db *SQLiteFileListDB)

Source from the content-addressed store, hash-verified

45}
46
47func (this *SQLiteFileListHashMap) Load(db *SQLiteFileListDB) error {
48 // 如果系统内存过小,我们不缓存
49 if memutils.SystemMemoryGB() < 3 {
50 return nil
51 }
52
53 this.isAvailable = true
54
55 var lastId int64
56 var maxLoops = 50_000
57 for {
58 hashList, maxId, err := db.ListHashes(lastId)
59 if err != nil {
60 return err
61 }
62 if len(hashList) == 0 {
63 break
64 }
65 this.AddHashes(hashList)
66 lastId = maxId
67
68 maxLoops--
69 if maxLoops <= 0 {
70 break
71 }
72 }
73
74 this.isReady = true
75 return nil
76}
77
78func (this *SQLiteFileListHashMap) Add(hash string) {
79 if !this.isAvailable {

Callers 2

TestFileListHashMap_LoadFunction · 0.45
loadHashMapMethod · 0.45

Calls 2

AddHashesMethod · 0.95
ListHashesMethod · 0.80

Tested by 1

TestFileListHashMap_LoadFunction · 0.36