Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Add(u interface{}, value interface{}) (err error)
- func (c *Cache) AddOrUpdate(u interface{}, value interface{}) (err error)
- func (c *Cache) DumpStore()
- func (c *Cache) Get(u interface{}) (i interface{}, err error)
- func (c *Cache) LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error)
- func (c *Cache) Refresh(d time.Duration)
- func (c *Cache) Remove(u interface{}) (err error)
- func (c *Cache) SizeOf() int
- func (c *Cache) Update(u interface{}, value interface{}) (err error)
- type Cleanable
- type DataStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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. For example one thread might be storing values in the cache while a parallel thread is refreshing the cache.
func NewCache ¶
func NewCache(refresh func(val interface{}) interface{}) *Cache
NewCache creates a new data cache
func NewCacheWithExpiration ¶
NewCacheWithExpiration creates a new data cache
func (*Cache) AddOrUpdate ¶
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) DumpStore ¶
func (c *Cache) DumpStore()
DumpStore prints the whole data store for debuggin
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) Refresh ¶
Refresh : will parse the cache for expired entries and validate them We will be passhing a validation function as argument here Details TBD
type Cleanable ¶
type Cleanable interface {
Cleanup()
}
Cleanable is an interface that could be implemented by elements being inserted in cache with expiration
type DataStore ¶
type DataStore interface { Add(u interface{}, value interface{}) (err error) AddOrUpdate(u interface{}, value interface{}) (err error) Get(u interface{}) (i interface{}, err error) Remove(u interface{}) (err error) Refresh(d time.Duration) DumpStore() LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error) }
DataStore is the interface to a datastore that will evolve to hold basic values and also auto-refresh the cache. The DataStore is indexed by UUID values only