Documentation ¶
Index ¶
- Variables
- type MemoryCache
- func (bc *MemoryCache) ClearAll() error
- func (bc *MemoryCache) Decr(key string) error
- func (bc *MemoryCache) Delete(name string) error
- func (bc *MemoryCache) ExpiredCallback(name string) error
- func (bc *MemoryCache) Get(name string) interface{}
- func (bc *MemoryCache) GetAll() []interface{}
- func (bc *MemoryCache) GetAllEx() map[string]interface{}
- func (bc *MemoryCache) GetMulti(names []string) []interface{}
- func (bc *MemoryCache) Incr(key string) error
- func (bc *MemoryCache) IsExist(name string) bool
- func (bc *MemoryCache) Put(name string, value interface{}, expired int64) *MemoryItem
- func (bc *MemoryCache) StartAndGC(interval int) error
- func (bc *MemoryCache) ThrowError(str string) error
- type MemoryItem
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // clock time of recycling the expired cache items in memory. DefaultEvery int = 60 // 1 minute )
Functions ¶
This section is empty.
Types ¶
type MemoryCache ¶
type MemoryCache struct { Every int // run an expiration check Every clock time // contains filtered or unexported fields }
Memory cache adapter. it contains a RW locker for safe map storage.
func NewMemoryCache ¶
func NewMemoryCache(autoGC bool) *MemoryCache
NewMemoryCache returns a new MemoryCache.
func (*MemoryCache) Decr ¶
func (bc *MemoryCache) Decr(key string) error
Decrease counter in memory.
func (*MemoryCache) Delete ¶
func (bc *MemoryCache) Delete(name string) error
/ Delete cache in memory.
func (*MemoryCache) ExpiredCallback ¶
func (bc *MemoryCache) ExpiredCallback(name string) error
func (*MemoryCache) Get ¶
func (bc *MemoryCache) Get(name string) interface{}
Get cache from memory. if non-existed or expired, return nil.
func (*MemoryCache) GetAllEx ¶
func (bc *MemoryCache) GetAllEx() map[string]interface{}
func (*MemoryCache) GetMulti ¶
func (bc *MemoryCache) GetMulti(names []string) []interface{}
GetMulti gets caches from memory. if non-existed or expired, return nil.
func (*MemoryCache) Incr ¶
func (bc *MemoryCache) Incr(key string) error
Increase cache counter in memory. it supports int,int64,int32,uint,uint64,uint32.
func (*MemoryCache) IsExist ¶
func (bc *MemoryCache) IsExist(name string) bool
check cache exist in memory.
func (*MemoryCache) Put ¶
func (bc *MemoryCache) Put(name string, value interface{}, expired int64) *MemoryItem
Put cache to memory. if expired is 0, it will be cleaned by next gc operation ( default gc clock is 1 minute).
func (*MemoryCache) StartAndGC ¶
func (bc *MemoryCache) StartAndGC(interval int) error
start memory cache. it will check expiration in every clock time.
func (*MemoryCache) ThrowError ¶
func (bc *MemoryCache) ThrowError(str string) error
type MemoryItem ¶
Memory cache item.
func (*MemoryItem) RegisterExpiredCallback ¶
func (m *MemoryItem) RegisterExpiredCallback(fn func(m interface{}) error)
Click to show internal directories.
Click to hide internal directories.