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

Function getCacheOf

client/internal/cache/base.go:86–98  ·  view source on GitHub ↗
(c *Cache, k K)

Source from the content-addressed store, hash-verified

84}
85
86func getCacheOf[T any, K keyType](c *Cache, k K) (v *T, ok bool) {
87 typstr := reflect.ValueOf(v).Type().String()
88 typ := cacheTypesMap[typstr]
89 if typ == 0 {
90 return
91 }
92 key := uint64(typ)<<32 | uint64(k)
93 unsafev, ok := c.m.Load(key)
94 if ok {
95 v = (*T)(unsafev)
96 }
97 return
98}
99
100func rangeCacheOf[T any, K keyType](c *Cache, iter func(k K, v *T) bool) {
101 typ := cacheTypesMap[typenameof[T]()]

Callers 5

GetUIDMethod · 0.85
GetFriendMethod · 0.85
GetGroupInfoMethod · 0.85
GetGroupMemberMethod · 0.85
GetRKeyInfoMethod · 0.85

Calls 2

TypeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected