Documentation ¶
Overview ¶
Package zcache cache operation
Index ¶
- Variables
- func Clear()
- func Get(key string) (value interface{}, err error)
- func GetInt(key string) (value int, err error)
- func GetString(key string) (value string, err error)
- func MustGet(key string, ...) (data interface{}, err error)
- func Set(key string, data interface{}, lifeSpan uint, interval ...bool)
- func SetDeleteCallback(fn func(key string) bool)
- func SetLogger(logger *zlog.Logger)
- type CacheItemPair
- type CacheItemPairList
- type Item
- func (item *Item) AccessCount() int64
- func (item *Item) AccessedTime() time.Time
- func (item *Item) CreatedTime() time.Time
- func (item *Item) Data() interface{}
- func (item *Item) Key() interface{}
- func (item *Item) LifeSpan() time.Duration
- func (item *Item) LifeSpanUint() uint
- func (item *Item) RemainingLife() time.Duration
- func (item *Item) SetDeleteCallback(fn func(key string) bool)
- type Table
- func (table *Table) Add(key string, data interface{}, lifeSpan time.Duration, intervalLifeSpan ...bool) bool
- func (table *Table) Clear()
- func (table *Table) Count() int
- func (table *Table) Delete(key string) (*Item, error)
- func (table *Table) Exists(key string) bool
- func (table *Table) ForEach(trans func(key string, value interface{}) bool)
- func (table *Table) ForEachRaw(trans func(key string, value *Item) bool)
- func (table *Table) Get(key string, args ...interface{}) (value interface{}, err error)
- func (table *Table) GetInt(key string, args ...interface{}) (value int, err error)
- func (table *Table) GetString(key string, args ...interface{}) (value string, err error)
- func (table *Table) GetT(key string, args ...interface{}) (*Item, error)
- func (table *Table) MostAccessed(count int64) []*Item
- func (table *Table) MustGet(key string, ...) (data interface{}, err error)
- func (table *Table) Set(key string, data interface{}, lifeSpan uint, interval ...bool) *Item
- func (table *Table) SetAddCallback(f func(*Item))
- func (table *Table) SetDeleteCallback(f func(key string) bool)
- func (table *Table) SetLoadNotCallback(f func(key string, args ...interface{}) *Item)
- func (table *Table) SetLogger(logger *zlog.Logger)
- func (table *Table) SetRaw(key string, data interface{}, lifeSpan time.Duration, intervalLifeSpan ...bool) *Item
Constants ¶
This section is empty.
Variables ¶
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 ¶
func MustGet ¶ added in v0.1.37
func MustGet(key string, do func(set func(data interface{}, lifeSpan time.Duration, interval ...bool)) ( err error)) (data interface{}, err error)
MustGet get the data of the specified key, set if it does not exist
func SetDeleteCallback ¶ added in v0.0.20
Types ¶
type CacheItemPair ¶
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 Item ¶ added in v0.0.20
Item Item
func NewCacheItem ¶ added in v0.1.29
NewCacheItem NewCacheItem
func (*Item) AccessCount ¶ added in v0.0.20
AccessCount AccessCount
func (*Item) AccessedTime ¶ added in v0.0.20
AccessedTime AccessedTime
func (*Item) CreatedTime ¶ added in v0.0.20
CreatedTime CreatedTime
func (*Item) LifeSpanUint ¶ added in v0.0.20
LifeSpanUint LifeSpanUint
func (*Item) RemainingLife ¶ added in v0.0.20
RemainingLife RemainingLife
func (*Item) SetDeleteCallback ¶ added in v0.0.20
SetDeleteCallback SetDeleteCallback
type Table ¶
Table Table
func (*Table) Add ¶ added in v0.0.19
func (table *Table) Add(key string, data interface{}, lifeSpan time.Duration, intervalLifeSpan ...bool) bool
Add if the cache does not exist then adding does not take effect
func (*Table) ForEachRaw ¶ added in v0.1.37
ForEachRaw traversing the cache
func (*Table) MostAccessed ¶
MostAccessed MostAccessed
func (*Table) MustGet ¶ added in v0.1.37
func (table *Table) MustGet(key string, do func(set func(data interface{}, lifeSpan time.Duration, interval ...bool)) ( err error)) (data interface{}, err error)
MustGet get the data of the specified key, set if it does not exist
func (*Table) SetAddCallback ¶
SetAddCallback SetAddCallback
func (*Table) SetDeleteCallback ¶
SetDeleteCallback SetDeleteCallback
func (*Table) SetLoadNotCallback ¶
SetLoadNotCallback SetLoadNotCallback