Documentation ¶
Index ¶
- type Cache
- type LRUCache
- func (lru *LRUCache) Contains(key interface{}) bool
- func (lru *LRUCache) Get(key interface{}) (value interface{}, ok bool)
- func (lru *LRUCache) Keys() []interface{}
- func (lru *LRUCache) Len() int
- func (lru *LRUCache) Purge()
- func (lru *LRUCache) Remove(key interface{}) (present bool)
- func (lru *LRUCache) Resize(size int) (evicted int)
- func (lru *LRUCache) Set(key interface{}, value interface{}) (evicted bool)
- func (lru *LRUCache) SetLogger(logger logger.Logger)
- func (lru *LRUCache) Updated() time.Time
- type Persistence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Set(key, value interface{}) (evicted bool) Contains(key interface{}) bool Get(key interface{}) (value interface{}, ok bool) Keys() []interface{} Len() int Purge() Remove(key interface{}) (present bool) Resize(size int) (evicted int) Updated() time.Time SetLogger(logger logger.Logger) }
Cache wrapper to integrate any 3rd party implementation
type LRUCache ¶
LRUCache is thread-safe LAST READ USED Cache
func NewLruCache ¶
NewLruCache creates a new LRU instance
func (*LRUCache) Keys ¶
func (lru *LRUCache) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*LRUCache) Set ¶
Set a new value if it is different from the previous one. Returns true if an eviction occurred.
type Persistence ¶
type Persistence struct {
// contains filtered or unexported fields
}
Persistence persist cache data to a storage
func NewPersistence ¶
NewPersistence creates a new instance for persisting data
func (*Persistence) LoadFromStore ¶
func (p *Persistence) LoadFromStore() error
LoadFromStore loads all stored data into specified cache
func (Persistence) SaveToStore ¶
func (p Persistence) SaveToStore() error
SaveToStore saves data to declared storage only if last update is greater than persisted time
Click to show internal directories.
Click to hide internal directories.