NewLocalDataCache creates a new LocalDataCache instance. It accepts an optional copier function. If a copier is provided, the Get method will return a deep copy of the cached value. This is critical for ensuring thread safety when caching reference types that might be mutated by consumers. This desi
(copier Copier[V])
| 43 | // NestedMapCopier returns a reusable Copier function for two-level nested maps: map[K1]map[K2]V. |
| 44 | func NestedMapCopier[M ~map[K1]map[K2]V, K1 comparable, K2 comparable, V any]() Copier[M] { |
| 45 | return func(in M) M { |
| 46 | if in == nil { |
| 47 | return nil |
| 48 | } |
| 49 | out := make(M, len(in)) |
| 50 | for k, inner := range in { |
| 51 | if inner == nil { |
| 52 | out[k] = nil |
| 53 | |
| 54 | continue |
| 55 | } |
| 56 | newInner := make(map[K2]V, len(inner)) |
nothing calls this directly
no outgoing calls
no test coverage detected