Skip to content
/ lazycache Public
generated from bep/golibtemplate

Thread safe in-memory LRU cache with non-blocking cache priming on cache misses.

License

Notifications You must be signed in to change notification settings

bep/lazycache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests on Linux, MacOS and Windows Go Report Card codecov GoDoc

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:

  • The API is generic
  • The cache can be resized while running.
  • When the number of entries overflows the defined cache size, the least recently used item gets discarded (LRU).

About

Thread safe in-memory LRU cache with non-blocking cache priming on cache misses.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages