https://github.com/koding/cache
Caching package for Go
https://github.com/koding/cache
Last synced: 9 months ago
JSON representation
Caching package for Go
- Host: GitHub
- URL: https://github.com/koding/cache
- Owner: koding
- License: mit
- Created: 2014-07-23T08:48:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-12-22T23:30:19.000Z (about 9 years ago)
- Last Synced: 2025-03-31T05:04:02.811Z (9 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/koding/cache
- Size: 65.4 KB
- Stars: 89
- Watchers: 9
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cache [](https://godoc.org/github.com/koding/cache) [](https://travis-ci.org/koding/cache)
Cache is a backend provider for common use cases
## Install and Usage
Install the package with:
```bash
go get github.com/koding/cache
```
Import it with:
```go
import "github.com/koding/cache"
```
Example
```go
// 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")
```
## Supported caching algorithms:
- 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