Documentation ¶
Overview ¶
Package data implements in memory caching methods for data
Index ¶
- type Cache
- func (r *Cache) Append(key interface{}, value []byte) bool
- func (r *Cache) Delete(key interface{})
- func (r *Cache) Get(key interface{}) ([]byte, bool)
- func (r *Cache) Len(key interface{}) int
- func (r *Cache) Set(key interface{}, value []byte) bool
- func (r *Cache) SetMaxSize(maxSize uint64)
- func (r *Cache) Stats() Stats
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { // Mutex is used for handling the concurrent // read/write requests for cache sync.Mutex // OnEvicted - callback function for eviction OnEvicted func(a ...interface{}) // contains filtered or unexported fields }
Cache holds the required variables to compose an in memory cache system which also provides expiring key mechanism and also maxSize
func NewCache ¶
NewCache creates an inmemory cache
maxSize is used for expiring objects before we run out of memory expiration is used for expiration of a key from cache
func (*Cache) Append ¶
Append will append new data to an existing key, if key doesn't exist it behaves like Set()
func (*Cache) Len ¶
Len returns length of the value of a given key, returns zero if key doesn't exist
Click to show internal directories.
Click to hide internal directories.