Benchmarks of in-memory cache libraries for Golang.
Execute Benchmark
go test -bench=. -benchmem -count 5 -benchtime=100000x > results/results.out
Results
All the benchmarks are performed in the Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz machine with 100K samples and 5 iterations.
Average ns / operation
Set Function
Get & Remove Function
Libraries
⚠ Please note that these libraries are benchmarked against storage of sample payloads (i.e. 1, 5, and 10 KB). You are encouraged to benchmark with your custom payloads.
akyoto/cache - Cache arbitrary data with an expiration time.
allegro/bigcache - Efficient cache for gigabytes of data written in Go.
bluele/gcache - An in-memory cache library for golang. It supports multiple eviction policies: LRU, LFU, ARC.
muesli/cache2go - Concurrency-safe Go caching library with expiration capabilities and access counters.
patrickmn/go-cache - An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.
sync#Map - Safe for concurrent use by multiple goroutine without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.
VictoriaMetrics/fastcache - Fast thread-safe in memory cache for big number of entries in Go. Minimizes GC overhead.