Documentation ¶
Overview ¶
Package cache : 数据缓存模块,可定时清理过期数据
Usage
package main import ( "github.com/xyzj/gopsu/cache" ) func main() { mycache:=cache.NewCache(1000) // max 1000 data defer mycache.End() // clean up and stop zhe data expire check mycache.Set("123","abc") v,ok:=mycache.Get("123") if !ok{ println("key not found") return } println(v) }
Index ¶
- type XCache
- func (xc *XCache) Clean()
- func (xc *XCache) End()
- func (xc *XCache) Get(k string) (interface{}, bool)
- func (xc *XCache) GetAndExpire(k string, expire time.Duration) (interface{}, bool)
- func (xc *XCache) GetAndRemove(k string) (interface{}, bool)
- func (xc *XCache) Len() int
- func (xc *XCache) Set(k string, v interface{}, expire time.Duration) bool
- func (xc *XCache) SetWithHold(k string, v interface{}, expire, timeout time.Duration) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type XCache ¶
type XCache struct {
// contains filtered or unexported fields
}
XCache 可设置超时的缓存字典
func NewCacheWithWriter ¶ added in v1.3.5
NewCacheWithWriter 创建新的缓存字典,并指定panic日志输出writer
max:字典大小,0-不限制(谨慎使用)
func (*XCache) GetAndExpire ¶
GetAndExpire 读取缓存数据,并延长缓存时效
func (*XCache) GetAndRemove ¶
GetAndRemove 读取缓存数据,并删除
Click to show internal directories.
Click to hide internal directories.