.. | ||
cache.go | ||
doc.go | ||
errors.go | ||
helper_test.go | ||
lru.go | ||
lru_nots.go | ||
lru_nots_test.go | ||
lru_test.go | ||
memory.go | ||
memory_nots.go | ||
memory_nots_test.go | ||
memory_test.go | ||
memory_ttl.go | ||
memory_ttl_test.go | ||
README.md |
Cache
Cache is a backend provider for common use cases
Install and Usage
Install the package with:
go get github.com/koding/cache
Import it with:
import "github.com/koding/cache"
Example
// create a cache with 2 second TTL
cache := NewMemoryWithTTL(2 * time.Second)
// start garbage collection for expired keys
cache.StartGC(time.Millisecond * 10)
// set item
err := cache.Set("test_key", "test_data")
// get item
data, err := cache.Get("test_key")