Documentation ¶
Index ¶
- func ToString() string
- type Cache
- func (c *Cache) Add(u interface{}, value interface{}) (err error)
- func (c *Cache) AddOrUpdate(u interface{}, value interface{})
- func (c *Cache) Get(u interface{}) (i interface{}, err error)
- func (c *Cache) GetReset(u interface{}, duration time.Duration) (interface{}, error)
- func (c *Cache) LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error)
- func (c *Cache) Remove(u interface{}) (err error)
- func (c *Cache) RemoveWithDelay(u interface{}, duration time.Duration) error
- func (c *Cache) SetTimeOut(u interface{}, timeout time.Duration) (err error)
- func (c *Cache) SizeOf() int
- func (c *Cache) ToString() string
- func (c *Cache) Update(u interface{}, value interface{}) (err error)
- type DataStore
- type ExpirationNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
Cache is the structure that involves the map of entries. The cache provides a sync mechanism and allows multiple clients at the same time.
func NewCacheWithExpiration ¶
NewCacheWithExpiration creates a new data cache
func NewCacheWithExpirationNotifier ¶
func NewCacheWithExpirationNotifier(name string, lifetime time.Duration, expirer ExpirationNotifier) *Cache
NewCacheWithExpirationNotifier creates a new data cache with notifier
func (*Cache) AddOrUpdate ¶
func (c *Cache) AddOrUpdate(u interface{}, value interface{})
AddOrUpdate adds a new value in the cache or updates the existing value if needed. If an update happens the timestamp is also updated.
func (*Cache) GetReset ¶
GetReset changes the value of an entry into the cache and updates the timestamp
func (*Cache) LockedModify ¶
func (c *Cache) LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error)
LockedModify locks the data store
func (*Cache) RemoveWithDelay ¶ added in v1.0.58
RemoveWithDelay removes the entry from the cache after a certain duration
func (*Cache) SetTimeOut ¶
SetTimeOut sets the time out of an entry to a new value
type DataStore ¶
type DataStore interface { Add(u interface{}, value interface{}) (err error) AddOrUpdate(u interface{}, value interface{}) Get(u interface{}) (i interface{}, err error) GetReset(u interface{}, duration time.Duration) (interface{}, error) Remove(u interface{}) (err error) RemoveWithDelay(u interface{}, duration time.Duration) (err error) LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error) SetTimeOut(u interface{}, timeout time.Duration) (err error) ToString() string }
DataStore is the interface to a datastore.
type ExpirationNotifier ¶
type ExpirationNotifier func(c DataStore, id interface{}, item interface{})
ExpirationNotifier is a function which will be called every time a cache expires an item