cacheinterface/README.md
Tyler 3e6d1a1cc2
All checks were successful
continuous-integration/drone/push Build is passing
Use proper header sizes in readme, add build status badge
2019-10-05 16:58:36 -04:00

30 lines
781 B
Markdown

CacheInterface
==============
[![Build Status](https://drone.meow.tf/api/badges/tyler/cacheinterface/status.svg)](https://drone.meow.tf/tyler/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.
```go
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.