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

Method Store

pkg/generic_sync/generic_sync.go:142–169  ·  view source on GitHub ↗

Store sets the value for a key.

(key K, value V)

Source from the content-addressed store, hash-verified

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

Callers 8

UploadFileMethod · 0.80
FileOperateFunction · 0.80
CheckFileStatusFunction · 0.80
SettingSystemTempDataMethod · 0.80
LoadOrStoreMethod · 0.80
RangeMethod · 0.80
missLockedMethod · 0.80
PostOperateFileOrDirFunction · 0.80

Calls 6

dirtyLockedMethod · 0.95
newEntryFunction · 0.85
LoadMethod · 0.80
tryStoreMethod · 0.80
unexpungeLockedMethod · 0.80
storeLockedMethod · 0.80

Tested by

no test coverage detected