Documentation ¶
Overview ¶
Package gocache 并发安全、支持lru、支持过期的缓存轮子
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrKeyNotFound key不存在错误 ErrKeyNotFound = fmt.Errorf("key not found") // ErrKeyIsExpired key过期错误 ErrKeyIsExpired = fmt.Errorf("key is expired") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache 缓存核心结构
func (*Cache) GetAndSet ¶ added in v0.0.2
GetAndSet 获取val,若val存在且未过期,则更新至缓存,否则通过singleflight的方式更新至缓存 若更新失败,则使用旧数据兜底并返回对应的error给调用方
type CacheOpt ¶
type CacheOpt struct {
// contains filtered or unexported fields
}
CacheOpt Cache参数选项结构
type UpdateCallback ¶ added in v0.0.2
type UpdateCallback func() (interface{}, error)
UpdateCallback 更新数据回调
Click to show internal directories.
Click to hide internal directories.