accesscache

package
v0.0.0-...-1dd6a0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2020 License: BSD-2-Clause Imports: 5 Imported by: 0

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL