Documentation ¶
Index ¶
Constants ¶
View Source
const ( // LRUAlgorithm ... LRUAlgorithm = "lru" // LFUAlgorithm ... LFUAlgorithm = "lfu" // DefaultSize .. DefaultSize = 100 // DefaultExpiryTime ... DefaultExpiryTime = time.Second * 10 // DefaultAlgorithm ... DefaultAlgorithm = LRUAlgorithm )
Variables ¶
View Source
var ( // ErrMissed ... ErrMissed = errors.New("Cache item's missing") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Set(key string, value interface{}) error Get(key string) (val interface{}, err error) Delete(key string) (err error) GetKeys() (keys []string, err error) ClearCache() (err error) }
Cache represent the public API that will available used by user
type Option ¶
type Option struct { AlgorithmType string // represent the algorithm type ExpiryTime time.Duration // represent the expiry time of each stored item MaxSizeItem uint64 // Max size of item for eviction MaxMemory uint64 // Max Memory of item stored for eviction }
Option ...
func (*Option) SetAlgorithm ¶
SetAlgorithm will set the algorithm value
func (*Option) SetExpiryTime ¶
SetExpiryTime will set the expiry time
func (*Option) SetMaxMemory ¶
SetMaxMemory will set the maximum memory will used for cache
func (*Option) SetMaxSizeItem ¶
SetMaxSizeItem will set the maximum size of item in cache
Click to show internal directories.
Click to hide internal directories.