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

Method Stat

internal/caches/list_memory.go:341–362  ·  view source on GitHub ↗
(check func(hash string) bool)

Source from the content-addressed store, hash-verified

339}
340
341func (this *MemoryList) Stat(check func(hash string) bool) (*Stat, error) {
342 this.locker.RLock()
343 defer this.locker.RUnlock()
344
345 result := &Stat{
346 Count: 0,
347 Size: 0,
348 }
349 for _, itemMap := range this.itemMaps {
350 for hash, item := range itemMap {
351 if !item.IsExpired() {
352 // 检查文件是否存在、内容是否正确等
353 if check != nil && check(hash) {
354 result.Count++
355 result.ValueSize += item.Size()
356 result.Size += item.TotalSize()
357 }
358 }
359 }
360 }
361 return result, nil
362}
363
364// Count 总数量
365func (this *MemoryList) Count() (int64, error) {

Callers 2

TestMemoryList_StatFunction · 0.95

Calls 5

RLockMethod · 0.80
RUnlockMethod · 0.80
IsExpiredMethod · 0.45
SizeMethod · 0.45
TotalSizeMethod · 0.45

Tested by 2

TestMemoryList_StatFunction · 0.76