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

Method Get

internal/caches/open_file_cache.go:66–87  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

64}
65
66func (this *OpenFileCache) Get(filename string) *OpenFile {
67 filename = filepath.Clean(filename)
68
69 this.locker.RLock()
70 pool, ok := this.poolMap[filename]
71 this.locker.RUnlock()
72 if ok {
73 file, consumed, consumedSize := pool.Get()
74 if consumed {
75 this.locker.Lock()
76 this.count--
77 this.usedSize -= consumedSize
78
79 // pool如果为空,也不需要从列表中删除,避免put时需要重新创建
80
81 this.locker.Unlock()
82 }
83
84 return file
85 }
86 return nil
87}
88
89func (this *OpenFileCache) Put(filename string, file *OpenFile) {
90 filename = filepath.Clean(filename)

Callers 3

consumeHeadMethod · 0.45

Calls 5

RLockMethod · 0.80
RUnlockMethod · 0.80
CleanMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 2