Cache is a backend provider for common use cases
Install the package with:
go get github.com/koding/cacheImport it with:
import"github.com/koding/cache"Example
// create a cache with 2 second TTLcache:=NewMemoryWithTTL(2*time.Second)
// start garbage collection for expired keyscache.StartGC(time.Millisecond*10)
// set itemerr:=cache.Set("test_key", "test_data")
// get itemdata, err:=cache.Get("test_key")- MemoryNoTS : provides a non-thread safe in-memory caching system
- Memory : provides a thread safe in-memory caching system, built on top of MemoryNoTS cache
- LRUNoTS : provides a non-thread safe, fixed size in-memory caching system, built on top of MemoryNoTS cache
- LRU : provides a thread safe, fixed size in-memory caching system, built on top of LRUNoTS cache
- MemoryTTL : provides a thread safe, expiring in-memory caching system, built on top of MemoryNoTS cache
- ShardedNoTS : provides a non-thread safe sharded cache system, built on top of a cache interface
- ShardedTTL : provides a thread safe, expiring in-memory sharded cache system, built on top of ShardedNoTS over MemoryNoTS
- LFUNoTS : provides a non-thread safe, fixed size in-memory caching system, built on top of MemoryNoTS cache
- LFU : provides a thread safe, fixed size in-memory caching system, built on top of LFUNoTS cache