Documentation ¶
Index ¶
- Constants
- Variables
- func GetBool(v interface{}) bool
- func GetFloat64(v interface{}) float64
- func GetInt(v interface{}) int
- func GetInt64(v interface{}) int64
- func GetString(v interface{}) string
- func Register(name string, adapter Store)
- type Cache
- type CacheItem
- type GarbageCollector
- type SerializeHelper
- type Serializer
- type Store
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, it cannot be increased or decreased`) )
Functions ¶
Types ¶
type Cache ¶
type Cache interface { // get cached value by key. Get(key string) ([]byte, error) // set cached value with key and expire time. Put(key string, data []byte, expire time.Duration) error // delete cached value by key. Delete(key string) error // check if cached value exists or not. IsExist(key string) bool // clear all cache. ClearAll() error }
Cache interface contains all behaviors for cache adapter.
type GarbageCollector ¶
type GarbageCollector interface { //StartAndTrashGc(config string) error TrashGc(interval time.Duration) }
Some caches like redis automatically clear out the cache But for the filesystem and in memory, this cannot. Caches that have to manually clear out the cached data should implement this method. start trash gc routine based on config string settings.
type SerializeHelper ¶
type SerializeHelper struct { }
a helper types to serialize and deserialize
func (*SerializeHelper) DeSerialized ¶
func (sh *SerializeHelper) DeSerialized(data []byte, i interface{}) error
Writes a byte array into a type. use the encoding/gob package
func (*SerializeHelper) Serialized ¶
func (sh *SerializeHelper) Serialized(i interface{}) ([]byte, error)
Convert a given type into a byte array use the encoding/gob package
type Serializer ¶
type Serializer interface { Serialized(i interface{}) ([]byte, error) DeSerialized(data []byte, i interface{}) error }
func NewCacheSerializer ¶
func NewCacheSerializer() Serializer
Click to show internal directories.
Click to hide internal directories.