Documentation ¶
Overview ¶
Package cache 缓存 异步更新
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { SetOnUpdateError(func(err interface{})) Value() interface{} ForceUpdate() GetUpdate() time.Time }
func New ¶
func New(interval time.Duration, updateMethod UpdateMehtod) Cache
New 创建一个Cache对象timeupdate
func NewBlockCache ¶ added in v1.1.0
func NewBlockCache(interval time.Duration, updateMethod UpdateMehtod) Cache
NewBlockCache 创建一个Cache对象
type CacheBlock ¶ added in v1.1.0
type CacheBlock struct {
// contains filtered or unexported fields
}
CacheBlock 缓存 对比 默认 CacheInterval 的. 该方法有阻塞效果. 就是更新过程会阻塞
func (*CacheBlock) Destroy ¶ added in v1.1.0
func (cache *CacheBlock) Destroy()
Destroy 异步更新必须调用Destroy, 销毁对象
func (*CacheBlock) ForceUpdate ¶ added in v1.2.0
func (cache *CacheBlock) ForceUpdate()
ForceUpdate 强制更新
func (*CacheBlock) GetUpdate ¶ added in v1.1.0
func (cache *CacheBlock) GetUpdate() time.Time
Value 获取缓存的值
func (*CacheBlock) SetOnUpdateError ¶ added in v1.1.0
func (cache *CacheBlock) SetOnUpdateError(errFunc func(err interface{}))
SetOnUpdateError 默认false
func (*CacheBlock) SetShare ¶ added in v1.1.0
func (cache *CacheBlock) SetShare(share interface{})
func (*CacheBlock) Value ¶ added in v1.1.0
func (cache *CacheBlock) Value() interface{}
Value 获取缓存的值
type CacheInterval ¶ added in v1.1.0
type CacheInterval struct {
// contains filtered or unexported fields
}
CacheInterval 加一层为了 自动析构 自动释放线程
func (*CacheInterval) ForceUpdate ¶ added in v1.2.0
func (cache *CacheInterval) ForceUpdate()
Value 获取缓存的值
func (*CacheInterval) GetUpdate ¶ added in v1.1.0
func (cache *CacheInterval) GetUpdate() time.Time
GetUpdate 获取缓存的值
func (*CacheInterval) SetOnUpdateError ¶ added in v1.1.0
func (cache *CacheInterval) SetOnUpdateError(errFunc func(err interface{}))
SetOnUpdateError 默认false
func (*CacheInterval) SetShare ¶ added in v1.1.0
func (cache *CacheInterval) SetShare(share interface{})
func (*CacheInterval) Value ¶ added in v1.1.0
func (cache *CacheInterval) Value() interface{}
Value 获取缓存的值
Click to show internal directories.
Click to hide internal directories.