MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Load

Method Load

pkg/generic_sync/map.go:109–132  ·  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

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

Callers 15

HasMethod · 0.95
postMethod · 0.45
createSessionMethod · 0.45
signMethod · 0.45
requestMethod · 0.45
GetAccessTokenMethod · 0.45
GetRefreshTokenMethod · 0.45
DeleteConfigMethod · 0.45
GetConfigMethod · 0.45
HasMethod · 0.45
GetMethod · 0.45

Calls 3

missLockedMethod · 0.95
loadMethod · 0.80
UnlockMethod · 0.65

Tested by 4

TestDoDupSuppressFunction · 0.36
TestPanicDoFunction · 0.36
TestConcurrentRangeFunction · 0.36