kvcache

package
v0.0.0-...-3eddca5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(string, UpdateFunc) (interface{}, error)
	GetStats() (inserts, hits, misses uint64)
	Evict(string)
	Clear()
}

func NewLRUMemCache

func NewLRUMemCache(maxBytes int) Cache

func NewLRUTimeoutMemCache

func NewLRUTimeoutMemCache(maxBytes, maxAge int) Cache

type LRUMemCache

type LRUMemCache struct {
	// contains filtered or unexported fields
}

func (*LRUMemCache) Clear

func (c *LRUMemCache) Clear()

func (*LRUMemCache) Evict

func (c *LRUMemCache) Evict(key string)

func (*LRUMemCache) Get

func (c *LRUMemCache) Get(key string, update UpdateFunc) (interface{}, error)

func (LRUMemCache) GetStats

func (c LRUMemCache) GetStats() (uint64, uint64, uint64)

type LRUTimeoutMemCache

type LRUTimeoutMemCache struct {
	// contains filtered or unexported fields
}

func (*LRUTimeoutMemCache) Clear

func (c *LRUTimeoutMemCache) Clear()

func (*LRUTimeoutMemCache) Evict

func (c *LRUTimeoutMemCache) Evict(key string)

func (*LRUTimeoutMemCache) Get

func (c *LRUTimeoutMemCache) Get(
	key string, update UpdateFunc,
) (interface{}, error)

func (LRUTimeoutMemCache) GetStats

func (c LRUTimeoutMemCache) GetStats() (uint64, uint64, uint64)

type UpdateFunc

type UpdateFunc func() (value interface{}, size int, err error)

UpdateFunc is called if a cache item doesn't exists. It should return the new value, the size of the value (not including key), and an error.

Jump to

Keyboard shortcuts

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