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

Method Store

internal/cache/weak_cache.go:39–57  ·  view source on GitHub ↗
(key K, value *V)

Source from the content-addressed store, hash-verified

37}
38
39func (c *WeakCacheMap[K, V]) Store(key K, value *V) {
40 c.mu.Lock()
41 defer c.mu.Unlock()
42 entry, exists := c.m[key]
43 if exists {
44 entry.cleanup.Stop()
45 } else {
46 entry = &weakCacheEntry[V]{}
47 c.m[key] = entry
48 }
49 entry.weakPtr = weak.Make(value)
50 entry.cleanup = runtime.AddCleanup(value, func(struct{}) {
51 c.mu.Lock()
52 defer c.mu.Unlock()
53 if c.m[key] == entry {
54 delete(c.m, key)
55 }
56 }, struct{}{})
57}
58
59func (c *WeakCacheMap[K, V]) Delete(key K) bool {
60 c.mu.Lock()

Callers 11

BuildIndexFunction · 0.45
consumeMethod · 0.45
initStorageFunction · 0.45
GetBalancedStorageFunction · 0.45
BeginManualScanFunction · 0.45
AddURLMethod · 0.45
StatusMethod · 0.45
MemoryGrowCheckFunction · 0.45
finishBufMethod · 0.45
NewReadAtSeekerFunction · 0.45
ReadAtMethod · 0.45

Calls 2

UnlockMethod · 0.65
StopMethod · 0.45

Tested by

no test coverage detected