zcache

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound ErrKeyNotFound
	ErrKeyNotFound = errors.New("key is not in cache")
	// ErrKeyNotFoundAndNotCallback ErrKeyNotFoundAndNotCallback
	ErrKeyNotFoundAndNotCallback = errors.New("key is not in cache and no callback is set")
)

Functions

This section is empty.

Types

type CacheItem

type CacheItem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CacheItem CacheItem

func (*CacheItem) AccessCount

func (item *CacheItem) AccessCount() int64

AccessCount AccessCount

func (*CacheItem) AccessedTime

func (item *CacheItem) AccessedTime() time.Time

AccessedTime AccessedTime

func (*CacheItem) CreatedTime

func (item *CacheItem) CreatedTime() time.Time

CreatedTime CreatedTime

func (*CacheItem) Data

func (item *CacheItem) Data() interface{}

Data Data

func (*CacheItem) KeepAlive

func (item *CacheItem) KeepAlive()

KeepAlive KeepAlive

func (*CacheItem) Key

func (item *CacheItem) Key() interface{}

Key Key

func (*CacheItem) LifeSpan

func (item *CacheItem) LifeSpan() time.Duration

LifeSpan LifeSpan

func (*CacheItem) SetDeleteCallback

func (item *CacheItem) SetDeleteCallback(f func(interface{}))

SetDeleteCallback SetDeleteCallback

type CacheItemPair

type CacheItemPair struct {
	Key         interface{}
	AccessCount int64
}

CacheItemPair maps key to access counter

type CacheItemPairList

type CacheItemPairList []CacheItemPair

CacheItemPairList CacheItemPairList

func (CacheItemPairList) Len

func (p CacheItemPairList) Len() int

func (CacheItemPairList) Less

func (p CacheItemPairList) Less(i, j int) bool

func (CacheItemPairList) Swap

func (p CacheItemPairList) Swap(i, j int)

type Table

type Table struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Table Table

func New

func New(table string) *Table

New New

func (*Table) Clear

func (table *Table) Clear()

Clear Clear

func (*Table) Count

func (table *Table) Count() int

Count Count

func (*Table) Delete

func (table *Table) Delete(key interface{}) (*CacheItem, error)

Delete Delete

func (*Table) Exists

func (table *Table) Exists(key interface{}) bool

Exists Exists

func (*Table) ForEach

func (table *Table) ForEach(trans func(key interface{}, item *CacheItem))

ForEach ForEach

func (*Table) Get

func (table *Table) Get(key interface{}, args ...interface{}) (*CacheItem, error)

Get Get

func (*Table) MostAccessed

func (table *Table) MostAccessed(count int64) []*CacheItem

MostAccessed MostAccessed

func (*Table) NotFoundAdd

func (table *Table) NotFoundAdd(key interface{}, lifeSpan time.Duration, data interface{}) bool

NotFoundAdd NotFoundAdd

func (*Table) Set

func (table *Table) Set(key interface{}, lifeSpan time.Duration, data interface{}) *CacheItem

Set Set

func (*Table) SetAddCallback

func (table *Table) SetAddCallback(f func(*CacheItem))

SetAddCallback SetAddCallback

func (*Table) SetDeleteCallback

func (table *Table) SetDeleteCallback(f func(*CacheItem))

SetDeleteCallback SetDeleteCallback

func (*Table) SetLoadNotCallback

func (table *Table) SetLoadNotCallback(f func(interface{}, ...interface{}) *CacheItem)

SetLoadNotCallback SetLoadNotCallback

func (*Table) SetLogger

func (table *Table) SetLogger(logger *log.Logger)

SetLogger SetLogger

Jump to

Keyboard shortcuts

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