Documentation
¶
Index ¶
- Constants
- type CachePolicy
- type CrossPolicy
- type DBGetterFunc
- type OperationAttr
- type OperationAttrs
- type RedisStringOperation
- func (this *RedisStringOperation) Get(key string) *Result.ErrorResult
- func (this *RedisStringOperation) MGet(keys ...string) *Result.ErrorResult
- func (this *RedisStringOperation) Name() string
- func (this *RedisStringOperation) Set(key string, value interface{}, attrs ...*OperationAttr) *Result.ErrorResult
- type SimpleCache
Constants ¶
View Source
const ( ATTR_EXPIRE = "expr" //过期时间 ATTR_NX = "nx" // setnx ATTR_XX = "xx" // setxx )
View Source
const ( Serilizer_JSON = "json" Serilizer_GOB = "gob" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachePolicy ¶
type CachePolicy interface { Before(key string) //之前执行 IfNil(key string, v interface{}) //当空值是操作 SetOperation(opt *RedisStringOperation) //设置处理器 目前支持string }
type CrossPolicy ¶
type CrossPolicy struct { KeyRegx string //检查key的正则 Expire time.Duration //可以配置查找失败过期时间 // contains filtered or unexported fields }
缓存穿透 策略
func NewCrossPolicy ¶
func NewCrossPolicy(keyRegx string, expire time.Duration) *CrossPolicy
func (*CrossPolicy) Before ¶
func (this *CrossPolicy) Before(key string)
func (*CrossPolicy) IfNil ¶
func (this *CrossPolicy) IfNil(key string, v interface{})
func (*CrossPolicy) SetOperation ¶
func (this *CrossPolicy) SetOperation(opt *RedisStringOperation)
type OperationAttr ¶
type OperationAttr struct { Name string Value interface{} }
属性
func WithExpire ¶
func WithExpire(t time.Duration) *OperationAttr
func WithNX ¶
func WithNX() *OperationAttr
func WithXX ¶
func WithXX() *OperationAttr
type OperationAttrs ¶
type OperationAttrs []*OperationAttr
func (OperationAttrs) Find ¶
func (this OperationAttrs) Find(name string) *Result.ErrorResult
type RedisStringOperation ¶
专门处理string类型的操作
func NewStringOperation ¶
func NewStringOperation() *RedisStringOperation
func (*RedisStringOperation) Get ¶
func (this *RedisStringOperation) Get(key string) *Result.ErrorResult
func (*RedisStringOperation) MGet ¶
func (this *RedisStringOperation) MGet(keys ...string) *Result.ErrorResult
func (*RedisStringOperation) Name ¶
func (this *RedisStringOperation) Name() string
func (*RedisStringOperation) Set ¶
func (this *RedisStringOperation) Set(key string, value interface{}, attrs ...*OperationAttr) *Result.ErrorResult
type SimpleCache ¶
type SimpleCache struct { Operation *RedisStringOperation //操作类 Expire time.Duration // 过期时间 DBGetter DBGetterFunc // 一旦缓存中没有 DB获取的方法 Serilizer string // 序列化方式 Policy CachePolicy //验证策略 }
func NewSimpleCache ¶
func NewSimpleCache(operation *RedisStringOperation, expire time.Duration, serilizer string) *SimpleCache
func (*SimpleCache) GetCacheForObject ¶
func (this *SimpleCache) GetCacheForObject(key string, obj interface{}) (ret Result.Any)
func (*SimpleCache) SetCache ¶
func (this *SimpleCache) SetCache(key string, value interface{})
设置缓存
func (*SimpleCache) SetCahPolicy ¶
func (this *SimpleCache) SetCahPolicy(policy CachePolicy)
Click to show internal directories.
Click to hide internal directories.