Documentation ¶
Index ¶
- Constants
- Variables
- func InitRedis(host string, port int, password string, db int) (err error)
- func Version() string
- type DBGttFunc
- type DBGttInterfaceFunc
- type DBGttJsonFunc
- type DBGttSimpleJsonFunc
- type DBGttStringFunc
- type Iterator
- type JsonGttFunc
- type OperationAttr
- type OperationAttrs
- type SimpleCache
- type SimpleInterfaceCache
- type SimpleJsonCache
- type SimpleJsonGttFunc
- type SimpleSimpleJsonCache
- type SimpleStringCache
- 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
)
Functions ¶
Types ¶
type DBGttInterfaceFunc ¶ added in v1.0.6
type DBGttInterfaceFunc func() interface{}
type DBGttJsonFunc ¶ added in v1.0.6
type DBGttJsonFunc func() interface{}
type DBGttSimpleJsonFunc ¶ added in v1.0.6
type DBGttSimpleJsonFunc func() *simplejson.Json
type DBGttStringFunc ¶ added in v1.0.6
type DBGttStringFunc func() string
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 SimpleInterfaceCache ¶ added in v1.0.6
type SimpleInterfaceCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttInterfaceFunc // 缓存不存在的操作 DB }
SimpleInterfaceCache 缓存
func NewSimpleInterfaceCache ¶ added in v1.0.6
func NewSimpleInterfaceCache(operation *StringOperation, expire time.Duration) *SimpleInterfaceCache
func (*SimpleInterfaceCache) GetCache ¶ added in v1.0.6
func (c *SimpleInterfaceCache) GetCache(key string) (ret string)
GetCache 获取缓存
func (*SimpleInterfaceCache) SetCache ¶ added in v1.0.6
func (c *SimpleInterfaceCache) SetCache(key string, value interface{})
SetCache 设置缓存
type SimpleJsonCache ¶ added in v1.0.6
type SimpleJsonCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttJsonFunc // 缓存不存在的操作 DB }
SimpleJsonCache 缓存
func NewSimpleJsonCache ¶ added in v1.0.6
func NewSimpleJsonCache(operation *StringOperation, expire time.Duration) *SimpleJsonCache
func (*SimpleJsonCache) GetCache ¶ added in v1.0.6
func (c *SimpleJsonCache) GetCache(key string) (ret interface{})
GetCache 获取缓存
func (*SimpleJsonCache) SetCache ¶ added in v1.0.6
func (c *SimpleJsonCache) SetCache(key string, value interface{})
SetCache 设置缓存
type SimpleJsonGttFunc ¶
type SimpleJsonGttFunc func() *simplejson.Json
type SimpleSimpleJsonCache ¶ added in v1.0.6
type SimpleSimpleJsonCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttSimpleJsonFunc // 缓存不存在的操作 DB }
SimpleSimpleJsonCache 缓存
func NewSimpleSimpleJsonCache ¶ added in v1.0.6
func NewSimpleSimpleJsonCache(operation *StringOperation, expire time.Duration) *SimpleSimpleJsonCache
func (*SimpleSimpleJsonCache) GetCache ¶ added in v1.0.6
func (c *SimpleSimpleJsonCache) GetCache(key string) (js *simplejson.Json)
GetCache 获取缓存
func (*SimpleSimpleJsonCache) SetCache ¶ added in v1.0.6
func (c *SimpleSimpleJsonCache) SetCache(key string, value interface{})
SetCache 设置缓存
type SimpleStringCache ¶ added in v1.0.6
type SimpleStringCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttStringFunc // 缓存不存在的操作 DB }
SimpleStringCache 缓存
func NewSimpleStringCache ¶ added in v1.0.6
func NewSimpleStringCache(operation *StringOperation, expire time.Duration) *SimpleStringCache
func (*SimpleStringCache) GetCache ¶ added in v1.0.6
func (c *SimpleStringCache) GetCache(key string) (ret string)
GetCache 获取缓存
func (*SimpleStringCache) SetCache ¶ added in v1.0.6
func (c *SimpleStringCache) SetCache(key string, value string)
SetCache 设置缓存
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.