https://github.com/zvelo/ttlru
A simple, goroutine-safe, cache with a global TTL, a fixed size and an LRU eviction policy for Go (golang)
https://github.com/zvelo/ttlru
Last synced: 5 months ago
JSON representation
A simple, goroutine-safe, cache with a global TTL, a fixed size and an LRU eviction policy for Go (golang)
- Host: GitHub
- URL: https://github.com/zvelo/ttlru
- Owner: zvelo
- License: mit
- Created: 2015-03-26T23:01:16.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T14:04:37.000Z (about 3 years ago)
- Last Synced: 2024-12-17T14:44:50.339Z (over 1 year ago)
- Language: Go
- Size: 30.3 KB
- Stars: 23
- Watchers: 38
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ttlru
[](https://godoc.org/zvelo.io/ttlru) [](https://circleci.com/gh/zvelo/ttlru) [](https://coveralls.io/r/zvelo/ttlru)
Package ttlru provides a simple, goroutine safe, cache with a fixed number of entries. Each entry has a per-cache defined TTL. This TTL is reset on both modification and access of the value. As a result, if the cache is full, and no items have expired, when adding a new item, the item with the soonest expiration will be evicted.
It is based on the LRU implementation in golang-lru:
[github.com/hashicorp/golang-lru](http://godoc.org/github.com/hashicorp/golang-lru)
Which in turn is based on the LRU implementation in groupcache:
[github.com/golang/groupcache/lru](http://godoc.org/github.com/golang/groupcache/lru)
It should be imported as `zvelo.io/ttlru`.