commit | 14eae340515388ca95aa8e7b86f0de668e981f54 | [log] [tgz] |
---|---|---|
author | MoonFruit <dkmoonfruit@gmail.com> | Thu Jan 16 18:29:26 2020 |
committer | Jeff Mitchell <jeffrey.mitchell@gmail.com> | Thu Jan 16 18:29:26 2020 |
tree | 635407bf580448ac91cc1265a72cac484c273f21 | |
parent | 7f827b33c0f158ec5dfbba01bb0b14a4541fd81d [diff] |
Add method PeekOrAdd to LRU Cache (#52)
This provides the lru
package which implements a fixed-size thread safe LRU cache. It is based on the cache in Groupcache.
Full docs are available on Godoc
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()))
}