Lazycache is a simple thread safe in-memory LRU cache. Under the hood it leverages the great simpleru package in golang-lru, with its exellent performance. One big difference between golang-lru
and this library is the GetOrCreate method, which provides:
- Non-blocking cache priming on cache misses.
- A guarantee that the prime function is only called once for a given key.
- The cache's RWMutex is not locked during the execution of the prime function, which should make it easier to reason about potential deadlocks.
Other notable features: