Documentation ¶
Index ¶
- Constants
- type Cache
- func (c *Cache) AllData() (map[string]interface{}, int)
- func (c *Cache) AllDatawithExpiry() map[string]snaphotData
- func (c *Cache) Del(key string)
- func (c *Cache) DeleteExpiredKeys()
- func (c *Cache) Exists(key string) bool
- func (c *Cache) ExistsNonBlocking(key string) bool
- func (c *Cache) Get(key string) (interface{}, error)
- func (c *Cache) HGet(key, field string) (interface{}, error)
- func (c *Cache) HGetAll(key string) (map[string]interface{}, error)
- func (c *Cache) HMset(key string, d interface{}, exp int) error
- func (c *Cache) Hset(key, field string, value interface{}, exp int)
- func (c *Cache) Set(key string, val interface{}, exp int)
- func (c *Cache) Update(key string, val interface{}) error
- type CacheFunction
- type CacheOptions
Constants ¶
const ( ErrKeyNotFound = "key does not Exists" ErrFieldNotFound = "field does not Exists" ErrNotHashvalue = "not a Hash value/table" ErrHmsetDataType = "invalid data type, Expected Struct/Map" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Data map[string]*dataHolder // contains filtered or unexported fields }
func (*Cache) AllData ¶
returns all data from the map with both key and value, expiry data will not be returned, returned data will be a copy of the original data
func (*Cache) AllDatawithExpiry ¶ added in v1.1.0
func (*Cache) Del ¶
Delete's the Item from the cache @This must be improved, So that deleted keys does'nt stay in the Heap.
func (*Cache) DeleteExpiredKeys ¶
func (c *Cache) DeleteExpiredKeys()
Deletes the node if it's expired from both Cache(Hash Table) and heap
func (*Cache) Exists ¶
Exists func receives the key check if it exists in the Hash Table and returns a boolean
func (*Cache) ExistsNonBlocking ¶
Internal exist func wihtout locking(c.mu.Lock)
func (*Cache) Get ¶
If exp is not nil, check if the element has expired or not Removes the element from the cache if expired, It does not remove The Node from the Heap, which will handled by the Sweaper. @This must be improved, So that deleted keys does'nt stay in the Heap.
func (*Cache) HMset ¶
HMset takes a Struct/Map as the value , if any other datatype is Provided it will return an error.
type CacheFunction ¶
type CacheFunction interface { Exists(key string) bool Set(key string, val interface{}, exp int) Get(key string) (interface{}, error) Del(key string) Update(key string, val interface{}) error Hset(key, field string, value interface{}, exp int) HGet(key, field string) (interface{}, error) HGetAll(key string) (map[string]interface{}, error) HMset(key string, d interface{}, exp int) error AllData() (map[string]interface{}, int) }
func NewCache ¶
func NewCache(options ...CacheOptions) CacheFunction
Initialize a New CacheFunction type which is an Interfaces for all the availabel function