Documentation
¶
Index ¶
- Constants
- Variables
- func InitClusterRedis(adds []string, password string) (err error)
- func InitRedis(host string, port int, password string, db int) (err error)
- func InitSentinelRedis(adds []string, masterName string, password string, db int) (err error)
- type DBGttFunc
- type Iterator
- type JsonGttFunc
- type OperationAttr
- type OperationAttrs
- type SimpleCache
- type SimpleJsonGttFunc
- type SliceResult
- type StringOperation
- type StringResult
Constants ¶
View Source
const ( AttrExpr = "expr" //过期时间 AttrNx = "nx" // setNx )
View Source
const ( SerializerJson = "json" SerializerSimpleJson = "simplejson" SerializerString = "string" )
Variables ¶
View Source
var ( Rdb *redis.Client RdbC *redis.ClusterClient )
Functions ¶
func InitClusterRedis ¶
InitClusterRedis 初始化连接 集群
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func NewIterator ¶
func NewIterator(data []interface{}) *Iterator
type JsonGttFunc ¶
type JsonGttFunc func() interface{}
type OperationAttr ¶
type OperationAttr struct { Name string Value interface{} }
func WithNX ¶
func WithNX() *OperationAttr
type OperationAttrs ¶
type OperationAttrs []*OperationAttr
func (OperationAttrs) Find ¶
func (a OperationAttrs) Find(name string) interface{}
type SimpleCache ¶
type SimpleCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttFunc // 缓存不存在的操作 DB JsonGetter JsonGttFunc // 缓存不存在的操作 JSON SimpleJsonGetter SimpleJsonGttFunc // 缓存不存在的操作 SimpleJson Serializer string // 序列化方式 }
SimpleCache 缓存
func NewSimpleCache ¶
func NewSimpleCache(operation *StringOperation, expire time.Duration, serializer string) *SimpleCache
func (*SimpleCache) GetCache ¶
func (c *SimpleCache) GetCache(key string) (ret interface{})
GetCache 获取缓存
func (*SimpleCache) GetCacheSimpleJson ¶
func (c *SimpleCache) GetCacheSimpleJson(key string) (js *simplejson.Json)
GetCacheSimpleJson 获取缓存配合SimpleJson插件
func (*SimpleCache) SetCache ¶
func (c *SimpleCache) SetCache(key string, value interface{})
SetCache 设置缓存
type SimpleJsonGttFunc ¶
type SimpleJsonGttFunc func() *simplejson.Json
type SliceResult ¶
type SliceResult struct { Result []interface{} Err error }
func NewSliceResult ¶
func NewSliceResult(result []interface{}, err error) *SliceResult
func (*SliceResult) Iter ¶
func (r *SliceResult) Iter() *Iterator
func (*SliceResult) UnwrapOr ¶
func (r *SliceResult) UnwrapOr(defaults []interface{}) []interface{}
UnwrapOr 空值情况下设置返回默认值
type StringOperation ¶
type StringOperation struct {
// contains filtered or unexported fields
}
func NewStringOperation ¶
func NewStringOperation() *StringOperation
func (*StringOperation) MGet ¶
func (o *StringOperation) MGet(keys ...string) *SliceResult
MGet 获取多个
func (*StringOperation) Set ¶
func (o *StringOperation) Set(key string, value interface{}, attrs ...*OperationAttr) *StringResult
Set 设置
type StringResult ¶
func NewStringResult ¶
func NewStringResult(result string, err error) *StringResult
func (*StringResult) UnwrapOr ¶
func (r *StringResult) UnwrapOr(defaults string) string
UnwrapOr 空值情况下设置返回默认值
func (*StringResult) UnwrapOrElse ¶
func (r *StringResult) UnwrapOrElse(f func() string) string
Click to show internal directories.
Click to hide internal directories.