Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is the instance of the cache. Use New to create
func New ¶
New creates a new cache instance with expiration. For cache with no expiration policy provide a value of 0 or less
func (Cache) Delete ¶ added in v1.0.1
func (c Cache) Delete(key Key)
Delete will remove the item with the provided key from the cache.
func (Cache) DeleteAll ¶ added in v1.0.1
func (c Cache) DeleteAll()
DeleteAll deletes all items from the cache.
func (Cache) Get ¶
Get will return the key value from the cache based on Equals together with boolean which will be true if the key was found in cache and false otherwise. If the key exists based on Equals, then the *Item will be returned together with status true. If the key exists but is expired. it will be removed from the cache and the method will return nil false
func (Cache) GetAll ¶
func (c Cache) GetAll() []Item
GetAll will return all items in the cache. If expiration on items is set GetAll will lazily remove all expired items and return the rest
func (Cache) ItemCount ¶
func (c Cache) ItemCount() int
ItemCount will return the count of the items in the list. Expired items will be included in the count
func (Cache) Set ¶
func (c Cache) Set(key Key, val interface{})
Set will add the key value in the cache. If the key already exists based on Equals, then the value and expiration will be updated. If the key already exists but is expired. it will be removed from the cache and the key value pair will be added as a new Item If the key does not exist a new Item will be added in the cache