158b9d07f3
continuous-integration/drone/push Build is passing
Details
|
||
---|---|---|
.drone.yml | ||
.gitignore | ||
LICENSE | ||
README.md | ||
cache.go | ||
go.mod | ||
go.sum | ||
lru.go | ||
lru_test.go | ||
memcache.go | ||
memcache_test.go | ||
memory.go | ||
memory_test.go | ||
redis.go | ||
redis_test.go |
README.md
CacheInterface
An experimental interface to use different caches interchangeably via URIs
Example Cache URIs:
redis://server:port?db=0&password=test
memcache://server1:11211,server2:11211
memory://
lru://?size=128
Code
The CacheInterface interface has all methods. All clients will implement this on a best-effort basis.
type CacheInterface interface {
Has(key string) bool
Get(key string) ([]byte, error)
Set(key string, val interface{}, ttl time.Duration) (err error)
Del(key string) error
}
Note: Set will automatically attempt to store byte arrays and strings directly, and encode the rest with JSON.