MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / refreshAllCacheOf

Function refreshAllCacheOf

client/internal/cache/base.go:51–74  ·  view source on GitHub ↗
(c *Cache, newcache map[K]*T)

Source from the content-addressed store, hash-verified

49}
50
51func refreshAllCacheOf[T any, K keyType](c *Cache, newcache map[K]*T) {
52 typstr := typenameof[T]()
53 typ := cacheTypesMap[typstr]
54 if typ == 0 {
55 return
56 }
57 c.refreshed.Store(typ, struct{}{})
58 key := uint64(typ) << 32
59 dellst := make([]uint64, 0, 64)
60 c.m.Range(func(k uint64, _ unsafe.Pointer) bool {
61 if k&key != 0 {
62 if _, ok := newcache[K(uint32(k))]; !ok {
63 dellst = append(dellst, k)
64 }
65 }
66 return true
67 })
68 for k, v := range newcache {
69 c.m.Store(key|uint64(k), unsafe.Pointer(v))
70 }
71 for _, k := range dellst {
72 c.m.Delete(k)
73 }
74}
75
76func setCacheOf[T any, K keyType](c *Cache, k K, v *T) {
77 typstr := reflect.ValueOf(v).Type().String()

Callers 5

RefreshAllFriendMethod · 0.85
RefreshGroupMembersMethod · 0.85
RefreshAllGroupMethod · 0.85
RefreshAllRKeyInfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected