Documentation
¶
Overview ¶
Package accesscache keeping most requested elements in memory Usage: m := NewAccessCache(<maximum byte size>) Store data: m.Set(<key>, <value>) Read data: <value>, exists = m.Get(<key>)
Index ¶
- type AccessCache
- func (c *AccessCache) Count() int
- func (c *AccessCache) Get(key string) (interface{}, bool)
- func (c *AccessCache) GetAverageDurationForGet() float64
- func (c *AccessCache) GetAverageDurationForSet() float64
- func (c *AccessCache) GetCacheSize() uint64
- func (c *AccessCache) GetItemSizes() map[string]uint64
- func (c *AccessCache) GetLastViewedKey() string
- func (c *AccessCache) Set(key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessCache ¶
type AccessCache struct {
// contains filtered or unexported fields
}
AccessCache Structure
func NewAccessCache ¶
func NewAccessCache(size uint64) AccessCache
NewAccessCache constructs a new cache where size is the maximum size in bytes
func (*AccessCache) Count ¶
func (c *AccessCache) Count() int
Count returns the number if cached items
func (*AccessCache) Get ¶
func (c *AccessCache) Get(key string) (interface{}, bool)
Get gets an item from cache by key
func (*AccessCache) GetAverageDurationForGet ¶
func (c *AccessCache) GetAverageDurationForGet() float64
GetAverageDurationForGet returns average ms for Get
func (*AccessCache) GetAverageDurationForSet ¶
func (c *AccessCache) GetAverageDurationForSet() float64
GetAverageDurationForSet returns average ms for Set
func (*AccessCache) GetCacheSize ¶
func (c *AccessCache) GetCacheSize() uint64
GetCacheSize gets the current cache size in bytes
func (*AccessCache) GetItemSizes ¶
func (c *AccessCache) GetItemSizes() map[string]uint64
GetItemSizes gets cache size in bytes of all items
func (*AccessCache) GetLastViewedKey ¶
func (c *AccessCache) GetLastViewedKey() string
GetLastViewedKey gets the last viewed key from the cache
func (*AccessCache) Set ¶
func (c *AccessCache) Set(key string, value interface{}) error
Set adds or updates an item from cache keep in mind that the object you are adding should be smaller than the maximum memory of the cache