{"modulePath":"github.com/pb33f/libopenapi","version":"v0.45.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package weakcache\n\nPackage weakcache provides a concurrency-safe cache keyed by pointer identity that does not keep its keys alive.\n\n## Types\n\n```go\ntype Cache[K, V any] struct {\n\t// contains filtered or unexported fields\n}\n```\nCache maps pointers to values without retaining the pointers. Entries are found by address and verified through a weak pointer, so a hit costs a map lookup, an entry is dropped once the garbage collector reclaims its key, and an object later allocated at a reused address never sees the entry of the object that lived there before.\n\nThe zero value is ready to use. Keys must not be nil.\n\n```go\nfunc (c *Cache[K, V]) Clear()\n```\nClear invalidates every entry. Invalidated entries for live keys are updated in place by their next Store and entries for unreachable keys are removed as the keys are reclaimed, so clearing never registers a second cleanup for a key that is still alive.\n\n```go\nfunc (c *Cache[K, V]) Len() int\n```\nLen reports the number of entries currently held, including invalidated entries that have not been replaced or reclaimed yet.\n\n```go\nfunc (c *Cache[K, V]) Load(key *K) (V, bool)\n```\nLoad returns the value stored for key, if there is one and it was stored after the last Clear.\n\n```go\nfunc (c *Cache[K, V]) Store(key *K, value V)\n```\nStore records value for key. The entry is dropped automatically after key becomes unreachable.\n\n","path":"github.com/pb33f/libopenapi/internal/weakcache","name":"weakcache","synopsis":"Package weakcache provides a concurrency-safe cache keyed by pointer identity that does not keep its keys alive.","isRedistributable":true}
