Clone this repo:
  1. 7087cb7 remove defer keyword to avoid overhead (#53) by guanw · 3 weeks ago master v0.5.1
  2. 20f1fb7 Add go.mod by Mitchell Hashimoto · 7 months ago v0.5.0
  3. 369ebec fmt by Mitchell Hashimoto · 7 months ago
  4. 0fb14ef Return concrete type not interface type by Armon Dadgar · 1 year, 2 months ago
  5. d47b7dc Merge branch 'riking-patch-1' by Armon Dadgar · 1 year, 2 months ago

golang-lru

This provides the lru package which implements a fixed-size thread safe LRU cache. It is based on the cache in Groupcache.

Documentation

Full docs are available on Godoc

Example

Using the LRU is very simple:

l, _ := New(128)
for i := 0; i < 256; i++ {
    l.Add(i, nil)
}
if l.Len() != 128 {
    panic(fmt.Sprintf("bad len: %v", l.Len()))
}