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

Method Store

pkg/generic_sync/map.go:148–175  ·  view source on GitHub ↗

Store sets the value for a key.

(key K, value V)

Source from the content-addressed store, hash-verified

146
147// Store sets the value for a key.
148func (m *MapOf[K, V]) Store(key K, value V) {
149 read, _ := m.read.Load().(readOnly[K, V])
150 if e, ok := read.m[key]; ok && e.tryStore(&value) {
151 return
152 }
153
154 m.mu.Lock()
155 read, _ = m.read.Load().(readOnly[K, V])
156 if e, ok := read.m[key]; ok {
157 if e.unexpungeLocked() {
158 // The entry was previously expunged, which implies that there is a
159 // non-nil dirty map and this entry is not in it.
160 m.dirty[key] = e
161 }
162 e.storeLocked(&value)
163 } else if e, ok := m.dirty[key]; ok {
164 e.storeLocked(&value)
165 } else {
166 if !read.amended {
167 // We're adding the first new key to the dirty map.
168 // Make sure it is allocated and mark the read-only map as incomplete.
169 m.dirtyLocked()
170 m.read.Store(readOnly[K, V]{m: read.m, amended: true})
171 }
172 m.dirty[key] = newEntry(value)
173 }
174 m.mu.Unlock()
175}
176
177// tryStore stores a value if the entry has not been expunged.
178//

Callers 15

InitMethod · 0.45
SetAccessTokenMethod · 0.45
SetRefreshTokenMethod · 0.45
SetTokenMethod · 0.45
SetConfigMethod · 0.45
SetMethod · 0.45
MakeDirMethod · 0.45
updateLastConnTimeMethod · 0.45
cleanLastConnTimeMethod · 0.45
AcquireReferenceMethod · 0.45
SubmitMethod · 0.45
call.goFile · 0.45

Calls 7

dirtyLockedMethod · 0.95
newEntryFunction · 0.85
tryStoreMethod · 0.80
unexpungeLockedMethod · 0.80
storeLockedMethod · 0.80
UnlockMethod · 0.65
LoadMethod · 0.45

Tested by 3

TestPanicDoFunction · 0.36
TestGoexitDoFunction · 0.36
TestConcurrentRangeFunction · 0.36