Documentation ¶
Index ¶
- func CheckPool() bool
- func CreateDefaultPool(config *Config) error
- func NewPool(cfg *Config) (pool *redis.Pool, err error)
- func NewStarter() *starter
- func XFPool(f func(p *redis.Pool) error) error
- func XPool() *redis.Pool
- type CommandPipe
- type CommonRedisCache
- func (*CommonRedisCache) Add(k string, v interface{}) error
- func (*CommonRedisCache) AddWithExp(k string, v interface{}, exp time.Duration) error
- func (*CommonRedisCache) Decrement(k string, v int64) error
- func (*CommonRedisCache) Delete(k string) bool
- func (*CommonRedisCache) Get(k string) (interface{}, bool)
- func (*CommonRedisCache) GetBool(k string) (bool, error)
- func (*CommonRedisCache) GetBoolWithExp(k string) (bool, int64, error)
- func (*CommonRedisCache) GetFloat64(k string) (float64, error)
- func (*CommonRedisCache) GetFloat64WithExp(k string) (float64, int64, error)
- func (*CommonRedisCache) GetInt(k string) (int, error)
- func (*CommonRedisCache) GetIntWithExp(k string) (int, int64, error)
- func (*CommonRedisCache) GetString(k string) (string, error)
- func (*CommonRedisCache) GetStringWithExp(k string) (string, int64, error)
- func (*CommonRedisCache) GetWithExp(k string) (interface{}, time.Time, bool)
- func (*CommonRedisCache) Increment(k string, v int64) error
- func (*CommonRedisCache) Replace(k string, v interface{}) error
- func (*CommonRedisCache) ReplaceWithExp(k string, v interface{}, exp time.Duration) error
- func (*CommonRedisCache) Set(k string, v interface{}) error
- func (*CommonRedisCache) SetWithExp(k string, v interface{}, exp time.Duration) error
- type Config
- type RedisCommand
- type ReplysPipe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStarter ¶
func NewStarter() *starter
Types ¶
type CommandPipe ¶
type CommandPipe [][]interface{}
pipeline 串行命令,减少网络开销 e.g.: {{"SET","name","ginger"},{"SET","key","value"},{"GET","key"}}
type CommonRedisCache ¶ added in v1.1.5
type CommonRedisCache struct{}
func NewCommonRedisCache ¶ added in v1.1.5
func NewCommonRedisCache() *CommonRedisCache
func (*CommonRedisCache) Add ¶ added in v1.1.5
func (*CommonRedisCache) Add(k string, v interface{}) error
添加一个不存在或已超时的键值
func (*CommonRedisCache) AddWithExp ¶ added in v1.1.5
func (*CommonRedisCache) AddWithExp(k string, v interface{}, exp time.Duration) error
添加一个不存在或已超时的键值,带超时
func (*CommonRedisCache) Decrement ¶ added in v1.1.5
func (*CommonRedisCache) Decrement(k string, v int64) error
自减int64
func (*CommonRedisCache) Delete ¶ added in v1.1.5
func (*CommonRedisCache) Delete(k string) bool
删除键值
func (*CommonRedisCache) Get ¶ added in v1.1.5
func (*CommonRedisCache) Get(k string) (interface{}, bool)
获取一个键值
func (*CommonRedisCache) GetBool ¶ added in v1.1.5
func (*CommonRedisCache) GetBool(k string) (bool, error)
获取一个布尔键值
func (*CommonRedisCache) GetBoolWithExp ¶ added in v1.1.5
func (*CommonRedisCache) GetBoolWithExp(k string) (bool, int64, error)
获取一个布尔键值
func (*CommonRedisCache) GetFloat64 ¶ added in v1.1.5
func (*CommonRedisCache) GetFloat64(k string) (float64, error)
获取一个浮点数键值
func (*CommonRedisCache) GetFloat64WithExp ¶ added in v1.1.5
func (*CommonRedisCache) GetFloat64WithExp(k string) (float64, int64, error)
获取一个浮点数键值
func (*CommonRedisCache) GetInt ¶ added in v1.1.5
func (*CommonRedisCache) GetInt(k string) (int, error)
获取一个整型键值
func (*CommonRedisCache) GetIntWithExp ¶ added in v1.1.5
func (*CommonRedisCache) GetIntWithExp(k string) (int, int64, error)
获取一个整型键值
func (*CommonRedisCache) GetString ¶ added in v1.1.5
func (*CommonRedisCache) GetString(k string) (string, error)
获取一个字符键值
func (*CommonRedisCache) GetStringWithExp ¶ added in v1.1.5
func (*CommonRedisCache) GetStringWithExp(k string) (string, int64, error)
获取一个字符键值
func (*CommonRedisCache) GetWithExp ¶ added in v1.1.5
func (*CommonRedisCache) GetWithExp(k string) (interface{}, time.Time, bool)
获取一个带过期时间的键值
func (*CommonRedisCache) Increment ¶ added in v1.1.5
func (*CommonRedisCache) Increment(k string, v int64) error
自增int64
func (*CommonRedisCache) Replace ¶ added in v1.1.5
func (*CommonRedisCache) Replace(k string, v interface{}) error
更新一个已存在且未过期的键值,不满足条件则报错
func (*CommonRedisCache) ReplaceWithExp ¶ added in v1.1.5
func (*CommonRedisCache) ReplaceWithExp(k string, v interface{}, exp time.Duration) error
更新一个已存在且未过期的键值,不满足条件则报错,带超时
func (*CommonRedisCache) Set ¶ added in v1.1.5
func (*CommonRedisCache) Set(k string, v interface{}) error
更新或添加一个键值,无论是否已存在
func (*CommonRedisCache) SetWithExp ¶ added in v1.1.5
func (*CommonRedisCache) SetWithExp(k string, v interface{}, exp time.Duration) error
更新或添加一个键值,无论是否已存在,带超时
type Config ¶
type Config struct { DbHost string // 主机地址 DbPort int // 主机端口 DbAuth bool // 是否开启鉴权 DbPasswd string // 鉴权密码 MaxActive int64 // 最大活动链接数。0为无限 MaxIdle int64 // 最大闲置链接数,0为无限 IdleTimeout int64 // 闲置链接超时时间 }
RedisDB配置
func DefaultConfig ¶
func DefaultConfig() *Config
type RedisCommand ¶ added in v1.1.5
type RedisCommand struct {
// contains filtered or unexported fields
}
func (*RedisCommand) GetRedisConn ¶ added in v1.1.5
func (p *RedisCommand) GetRedisConn() redis.Conn
从Redis连接池获取一个连接
func (*RedisCommand) P ¶ added in v1.1.5
func (p *RedisCommand) P(commands CommandPipe) (ReplysPipe, error)
func (*RedisCommand) R ¶ added in v1.1.5
func (p *RedisCommand) R(command string, args ...interface{}) (reply interface{}, err error)
单次执行命令的R函数,执行完命令自动关闭连接
type ReplysPipe ¶
type ReplysPipe []interface{}
Click to show internal directories.
Click to hide internal directories.