MCPcopy
hub / github.com/IceWhaleTech/CasaOS / Load

Method Load

pkg/generic_sync/generic_sync.go:103–126  ·  view source on GitHub ↗

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

(key K)

Source from the content-addressed store, hash-verified

101// value is present.
102// The ok result indicates whether value was found in the map.
103func (m *MapOf[K, V]) Load(key K) (value V, ok bool) {
104 read, _ := m.read.Load().(readOnly[K, V])
105 e, ok := read.m[key]
106 if !ok && read.amended {
107 m.mu.Lock()
108 // Avoid reporting a spurious miss if m.dirty got promoted while we were
109 // blocked on m.mu. (If further loads of the same key will not miss, it's
110 // not worth copying the dirty map for this key.)
111 read, _ = m.read.Load().(readOnly[K, V])
112 e, ok = read.m[key]
113 if !ok && read.amended {
114 e, ok = m.dirty[key]
115 // Regardless of whether the entry was present, record a miss: this key
116 // will take the slow path until the dirty map is promoted to the read
117 // map.
118 m.missLocked()
119 }
120 m.mu.Unlock()
121 }
122 if !ok {
123 return value, false
124 }
125 return e.load()
126}
127
128func (m *MapOf[K, V]) Has(key K) bool {
129 _, ok := m.Load(key)

Callers 13

HasMethod · 0.95
TestChunkMethod · 0.80
UploadFileMethod · 0.80
FileOperateFunction · 0.80
CheckFileStatusFunction · 0.80
SendFileOperateNotifyMethod · 0.80
StoreMethod · 0.80
LoadOrStoreMethod · 0.80
DeleteMethod · 0.80
RangeMethod · 0.80
dirtyLockedMethod · 0.80
InitSetupFunction · 0.80

Calls 2

missLockedMethod · 0.95
loadMethod · 0.80

Tested by

no test coverage detected