Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func SetWithExpiration ¶
SetWithExpiration 缓存一个对象,并设置过期时间
Types ¶
type Cache ¶
type Cache interface {
// Set 缓存一个对象
Set(key string, val interface{})
// SetWithExpiration 缓存一个对象,并设置过期时间
SetWithExpiration(key string, val interface{}, expiration time.Duration)
// Get 获取一个缓存对象
Get(key string) (value interface{}, found bool)
// Delete 删除一个缓存对象
Delete(key string)
// 实现ItemMap接口的所有方法
ItemMap
}
Cache 缓存器
type ItemMap ¶
type ItemMap interface {
// GetItem 获取缓存项
GetItem(key string) (*Item, bool)
// AddItem 添加缓存项
AddItem(key string, val *Item)
// RemoveItem 移除缓存项
RemoveItem(key string)
// Flush 清空缓存
Flush()
// Len 返回缓存对象数量
Len() int
// Range 遍历缓存对象,接受一个op函数,函数参数分别是key/value
// 返回true表示继续遍历,返回false表示停止遍历
Range(op func(string, interface{}) bool)
// ClearExpired 清空过期对象
ClearExpired()
}
ItemMap
Click to show internal directories.
Click to hide internal directories.