An open API service indexing awesome lists of open source software.

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)

Awesome Lists containing this project

README

          

# ttlru

[![GoDoc](https://godoc.org/zvelo.io/ttlru?status.svg)](https://godoc.org/zvelo.io/ttlru) [![Circle CI](https://circleci.com/gh/zvelo/ttlru.svg?style=svg)](https://circleci.com/gh/zvelo/ttlru) [![Coverage Status](https://coveralls.io/repos/zvelo/ttlru/badge.svg)](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`.