Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CacheEmptyValue = "" // 空缓存值
Functions ¶
func CheckCacheBase ¶
func CheckCacheBase(base CacheBase)
func CheckCacheInfo ¶
func CheckCacheInfo(cacheInfo interface{}) error
func CheckHashSubKey ¶
func CheckHashSubKey(subKey string)
Types ¶
type HashCache ¶
func (*HashCache) UpdateCacheKey ¶
type HotKeyOption ¶
type HotKeyOption struct {
// contains filtered or unexported fields
}
HotKeyOption 热key处理选项
func NewHotKeyOption ¶
func NewHotKeyOption(opts ...HotKeyOptionWrap) (*HotKeyOption, error)
func (*HotKeyOption) GetFromLocalCache ¶
func (o *HotKeyOption) GetFromLocalCache() (string, error)
func (*HotKeyOption) GetShardingKey ¶
func (o *HotKeyOption) GetShardingKey() string
func (*HotKeyOption) IsHotKey ¶
func (o *HotKeyOption) IsHotKey() bool
func (*HotKeyOption) SetToLocalCache ¶
func (o *HotKeyOption) SetToLocalCache(v string) error
func (*HotKeyOption) UseLocalCache ¶
func (o *HotKeyOption) UseLocalCache() bool
UseLocalCache 当需要解决热key问题时,优先考虑使用本地缓存
type HotKeyOptionWrap ¶
type HotKeyOptionWrap func(o *HotKeyOption)
func WithGetShardingKey ¶
func WithGetShardingKey(f func() string) HotKeyOptionWrap
func WithIsHotKey ¶
func WithIsHotKey(f func() bool) HotKeyOptionWrap
func WithLocalCache ¶
func WithLocalCache(localCache ILocalCache, cacheInfo *CacheBase) HotKeyOptionWrap
type ICacheInfo ¶
type ILocalCache ¶
type ILocalCache interface {
// Get 如果数据不存在,则会返回ErrLocalCacheNoData错误
Get(key string) (string, error)
Set(cacheInfo *CacheBase, value string) error
Del(key string) error
}
ILocalCache 本地缓存抽象,主要用于解决hot key
func NewWrapBigCache ¶
func NewWrapBigCache(bigCache *bigcache.BigCache) ILocalCache
func NewWrapGoCache ¶
func NewWrapGoCache(cache *goCache.Cache) ILocalCache
type StringCache ¶
type StringCache struct {
CacheBase
}
func NewStringCache ¶
func NewStringCache(key string, expTime time.Duration) *StringCache
func (*StringCache) BaseInfo ¶
func (c *StringCache) BaseInfo() CacheBase
func (*StringCache) UpdateCacheKey ¶
func (c *StringCache) UpdateCacheKey(key string)
Click to show internal directories.
Click to hide internal directories.