MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / NewLocalDataCache

Function NewLocalDataCache

lib/localcache/cache.go:45–53  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

43// NestedMapCopier returns a reusable Copier function for two-level nested maps: map[K1]map[K2]V.
44func 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))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected