Versions in this module Expand all Collapse all v0 v0.0.2 Jul 23, 2019 Changes in this version type CacheBuilder + func (cb *CacheBuilder) ExpiredFunc(expiredFunction ExpiredFunction) *CacheBuilder v0.0.1 Jul 23, 2019 Changes in this version + const TYPE_ARC + const TYPE_LFU + const TYPE_LRU + const TYPE_SIMPLE + var DebugMode bool + var EmptyErr = errors.New("cache is empty") + var KeyNotFoundError = errors.New("Key not found.") + var ReachedMaxSizeErr = errors.New("reached max size") + func Debug(args ...interface{}) + func Search(n int, f func(int) bool) int + func SearchFrom(to int, from int, f func(int) bool) int + func SliceInsert(s []interface{}, i int, e interface{}) []interface + func SliceInsert2(s []interface{}, i int, e interface{}) []interface + func SliceInsert3(s []interface{}, i int, e interface{}) []interface + func SliceInsert4(s []interface{}, i int, e interface{}) []interface + type ARC struct + func (c *ARC) Get(key interface{}) (interface{}, error) + func (c *ARC) GetALL(checkExpired bool) map[interface{}]interface{} + func (c *ARC) GetIFPresent(key interface{}) (interface{}, error) + func (c *ARC) Has(key interface{}) bool + func (c *ARC) Keys(checkExpired bool) []interface{} + func (c *ARC) Len(checkExpired bool) int + func (c *ARC) Purge() + func (c *ARC) Remove(key interface{}) bool + func (c *ARC) Set(key, value interface{}) error + func (c *ARC) SetWithExpire(key, value interface{}, expiration time.Duration) error + type AddedFunc func(interface{}, interface{}) + type Cache interface + Get func(key interface{}) (interface{}, error) + GetALL func(checkExpired bool) map[interface{}]interface{} + GetIFPresent func(key interface{}) (interface{}, error) + Has func(key interface{}) bool + Keys func(checkExpired bool) []interface{} + Len func(checkExpired bool) int + Purge func() + Remove func(key interface{}) bool + Set func(key, value interface{}) error + SetWithExpire func(key, value interface{}, expiration time.Duration) error + type CacheBuilder struct + func New(size int) *CacheBuilder + func (cb *CacheBuilder) ARC() *CacheBuilder + func (cb *CacheBuilder) AddedFunc(addedFunc AddedFunc) *CacheBuilder + func (cb *CacheBuilder) Build() Cache + func (cb *CacheBuilder) BuildOrderedCache() OrderedCache + func (cb *CacheBuilder) Clock(clock Clock) *CacheBuilder + func (cb *CacheBuilder) DeserializeFunc(deserializeFunc DeserializeFunc) *CacheBuilder + func (cb *CacheBuilder) EvictType(tp string) *CacheBuilder + func (cb *CacheBuilder) EvictedFunc(evictedFunc EvictedFunc) *CacheBuilder + func (cb *CacheBuilder) Expiration(expiration time.Duration) *CacheBuilder + func (cb *CacheBuilder) LFU() *CacheBuilder + func (cb *CacheBuilder) LRU() *CacheBuilder + func (cb *CacheBuilder) LoaderExpireFunc(loaderExpireFunc LoaderExpireFunc) *CacheBuilder + func (cb *CacheBuilder) LoaderFunc(loaderFunc LoaderFunc) *CacheBuilder + func (cb *CacheBuilder) PurgeVisitorFunc(purgeVisitorFunc PurgeVisitorFunc) *CacheBuilder + func (cb *CacheBuilder) SearchCompareFunction(searchFunction SearchCompareFunction) *CacheBuilder + func (cb *CacheBuilder) SerializeFunc(serializeFunc SerializeFunc) *CacheBuilder + func (cb *CacheBuilder) Simple() *CacheBuilder + func (cb *CacheBuilder) SortKeysFunc(sortKeysFunction SortKeysFunction) *CacheBuilder + type Clock interface + Now func() time.Time + func NewRealClock() Clock + type DeserializeFunc func(interface{}, interface{}) (interface{}, error) + type EvictedFunc func(interface{}, interface{}) + type ExpiredFunction func(interface{}) bool + type FakeClock interface + Advance func(d time.Duration) + func NewFakeClock() FakeClock + type Group struct + func (g *Group) Do(key interface{}, fn func() (interface{}, error), isWait bool) (interface{}, bool, error) + type LFUCache struct + func (c *LFUCache) Get(key interface{}) (interface{}, error) + func (c *LFUCache) GetALL(checkExpired bool) map[interface{}]interface{} + func (c *LFUCache) GetIFPresent(key interface{}) (interface{}, error) + func (c *LFUCache) Has(key interface{}) bool + func (c *LFUCache) Keys(checkExpired bool) []interface{} + func (c *LFUCache) Len(checkExpired bool) int + func (c *LFUCache) Purge() + func (c *LFUCache) Remove(key interface{}) bool + func (c *LFUCache) Set(key, value interface{}) error + func (c *LFUCache) SetWithExpire(key, value interface{}, expiration time.Duration) error + type LRUCache struct + func (c *LRUCache) Get(key interface{}) (interface{}, error) + func (c *LRUCache) GetALL(checkExpired bool) map[interface{}]interface{} + func (c *LRUCache) GetIFPresent(key interface{}) (interface{}, error) + func (c *LRUCache) Has(key interface{}) bool + func (c *LRUCache) Keys(checkExpired bool) []interface{} + func (c *LRUCache) Len(checkExpired bool) int + func (c *LRUCache) Purge() + func (c *LRUCache) Remove(key interface{}) bool + func (c *LRUCache) Set(key, value interface{}) error + func (c *LRUCache) SetWithExpire(key, value interface{}, expiration time.Duration) error + type LoaderExpireFunc func(interface{}) (interface{}, *time.Duration, error) + type LoaderFunc func(interface{}) (interface{}, error) + type OrderedCache interface + DeQueue func() (interface{}, interface{}, error) + DeQueueBatch func(count int) ([]interface{}, []interface{}, error) + EnQueue func(interface{}, interface{}) error + EnQueueBatch func([]interface{}, []interface{}) error + Get func(interface{}) (interface{}, error) + GetALL func() map[interface{}]interface{} + GetIFPresent func(interface{}) (interface{}, error) + GetKeysAndValues func() ([]interface{}, []interface{}) + GetTop func() (interface{}, interface{}, error) + Keys func() []interface{} + Len func() int + MoveFront func(interface{}) error + OrderedKeys func() []interface{} + Prepend func(interface{}, interface{}) error + PrependBatch func([]interface{}, []interface{}) error + PrintValues func(int) + Purge func() + Refresh func() + Remove func(interface{}) bool + RemoveExpired func(allowFailCount int) error + Sort func() + type PurgeVisitorFunc func(interface{}, interface{}) + type RealClock struct + func (rc RealClock) Now() time.Time + type SearchCompareFunction func(value interface{}, anotherValue interface{}) int + type SerializeFunc func(interface{}, interface{}) (interface{}, error) + type SimpleCache struct + func (c *SimpleCache) Get(key interface{}) (interface{}, error) + func (c *SimpleCache) GetALL(checkExpired bool) map[interface{}]interface{} + func (c *SimpleCache) GetIFPresent(key interface{}) (interface{}, error) + func (c *SimpleCache) Has(key interface{}) bool + func (c *SimpleCache) Keys(checkExpired bool) []interface{} + func (c *SimpleCache) Len(checkExpired bool) int + func (c *SimpleCache) Purge() + func (c *SimpleCache) Remove(key interface{}) bool + func (c *SimpleCache) Set(key, value interface{}) error + func (c *SimpleCache) SetWithExpire(key, value interface{}, expiration time.Duration) error + type SimpleOrderedCache struct + func (c *SimpleOrderedCache) DeQueue() (key interface{}, value interface{}, err error) + func (c *SimpleOrderedCache) DeQueueBatch(count int) (keys []interface{}, values []interface{}, err error) + func (c *SimpleOrderedCache) EnQueue(key interface{}, value interface{}) error + func (c *SimpleOrderedCache) EnQueueBatch(keys []interface{}, values []interface{}) error + func (c *SimpleOrderedCache) Get(key interface{}) (interface{}, error) + func (c *SimpleOrderedCache) GetALL() map[interface{}]interface{} + func (c *SimpleOrderedCache) GetIFPresent(key interface{}) (interface{}, error) + func (c *SimpleOrderedCache) GetKeysAndValues() (keys []interface{}, values []interface{}) + func (c *SimpleOrderedCache) GetTop() (key interface{}, value interface{}, err error) + func (c *SimpleOrderedCache) Keys() []interface{} + func (c *SimpleOrderedCache) Len() int + func (c *SimpleOrderedCache) MoveFront(key interface{}) error + func (c *SimpleOrderedCache) OrderedKeys() []interface{} + func (c *SimpleOrderedCache) Prepend(key interface{}, value interface{}) error + func (c *SimpleOrderedCache) PrependBatch(keys []interface{}, values []interface{}) error + func (c *SimpleOrderedCache) PrintValues(stamp int) + func (c *SimpleOrderedCache) Purge() + func (c *SimpleOrderedCache) Refresh() + func (c *SimpleOrderedCache) Remove(key interface{}) bool + func (c *SimpleOrderedCache) RemoveExpired(allowFailCount int) error + func (c *SimpleOrderedCache) Sort() + type SortKeysFunction func([]interface{}, []interface{}, func(interface{}) (interface{}, bool)) ([]interface{}, bool)