Documentation ¶
Index ¶
Constants ¶
View Source
const ( EXPIRES_DEFAULT = time.Duration(0) EXPIRES_FOREVER = time.Duration(-1) )
Variables ¶
View Source
var ( ErrCacheMiss = errors.New("Key not found") ErrCacheNotStored = errors.New("Data not stored") ErrCacheNotSupported = errors.New("Operation not supported") ErrCacheDataCannotBeIncreasedOrDecreased = errors.New(` Data isn't an integer/string type. Hence, it cannot be increased or decreased`) )
Functions ¶
func DefaultKeyFunc ¶
DefaultKeyFunc is the default implementation of cache keys All it does is to preprend "onecache:" to the key sent in by client code
Types ¶
type CacheSerializer ¶
type CacheSerializer struct { }
Helper to serialize and deserialize types
func NewCacheSerializer ¶
func NewCacheSerializer() *CacheSerializer
func (*CacheSerializer) DeSerialize ¶
func (b *CacheSerializer) DeSerialize(data []byte, i interface{}) error
Writes a byte array into a type.
func (*CacheSerializer) Serialize ¶
func (b *CacheSerializer) Serialize(i interface{}) ([]byte, error)
Convert a given type into a byte array Caveat -> Types you create might have to be registered with the encoding/gob package
type GarbageCollector ¶
type GarbageCollector interface {
GC()
}
Some stores like redis and memcache automatically clear out the cache But for the filesystem and in memory, this cannot be said. Stores that have to manually clear out the cached data should implement this method. It's implementation should re run this function everytime the interval is reached Say every 5 minutes.
type Serializer ¶
Directories ¶
Path | Synopsis |
---|---|
Package filesystem provides a filesystem cache implementation for onecache
|
Package filesystem provides a filesystem cache implementation for onecache |
Package memcached is a cache implementation for onecache which uses memcached
|
Package memcached is a cache implementation for onecache which uses memcached |
Package memory provides a lightweight in memory store for onecache Do take a look at other stores
|
Package memory provides a lightweight in memory store for onecache Do take a look at other stores |
Package redis provides a cache implementation of onecache using redis as the backend
|
Package redis provides a cache implementation of onecache using redis as the backend |
Click to show internal directories.
Click to hide internal directories.