(c *Cache, newcache map[K]*T)
| 49 | } |
| 50 | |
| 51 | func 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 | |
| 76 | func setCacheOf[T any, K keyType](c *Cache, k K, v *T) { |
| 77 | typstr := reflect.ValueOf(v).Type().String() |
no outgoing calls
no test coverage detected