Documentation
¶
Index ¶
- Constants
- func RedisSetAddr(addr string) redisoptions
- func RedisSetAuth(auth string) redisoptions
- func RedisSetErrRetry(errRetry int) redisoptions
- func RedisSetIdleTimeout(idleTimeout time.Duration) redisoptions
- func RedisSetIndexDB(indexdb int) redisoptions
- func RedisSetMaxActive(maxactive int) redisoptions
- func RedisSetMaxIdle(maxidle int) redisoptions
- func RedisSeterrFunc(errF errFunc) redisoptions
- type Args
- type Locker
- type RedisAccess
- type RedisHandleModel
Constants ¶
View Source
const (
// 锁时间长度,单位为秒
LOCK_TIMEOUT = 5
)
Variables ¶
This section is empty.
Functions ¶
func RedisSetErrRetry ¶
func RedisSetErrRetry(errRetry int) redisoptions
RedisSetErrRetry 设置出错重试次数,至少为 1
func RedisSetIdleTimeout ¶
RedisSetIdleTimeout 设置 Redis 的最大空闲连接等待时间 超过此时间后,空闲连接将被关闭(秒)
func RedisSetIndexDB ¶
func RedisSetIndexDB(indexdb int) redisoptions
RedisSetIndexDB 设置 Redis 默认的数据库索引
func RedisSetMaxActive ¶
func RedisSetMaxActive(maxactive int) redisoptions
RedisSetMaxActive 设置 Redis 的最大激活连接数 表示同时最多有 N 个连接,为 0 时表示没有限制
func RedisSetMaxIdle ¶
func RedisSetMaxIdle(maxidle int) redisoptions
RedisSetMaxIdle 设置 Redis 的最大空闲连接数 表示即使没有 Redis 连接时依然可以保持 N 个空闲的连接,而不被清除,随时处于待命状态
Types ¶
type Locker ¶
type Locker struct {
LockKey string // 锁的键
LockValue string // 锁的值
// contains filtered or unexported fields
}
func NewLocker ¶
func NewLocker(key, val string, getRedisF func() *RedisHandleModel, thgo *threads.SubThreadGo) *Locker
创建一个新的 Locker 实例
type RedisAccess ¶
type RedisAccess struct {
DBConobj *redis.Client // Redis 连接池
// contains filtered or unexported fields
}
RedisAccess 是 Redis 管理器
func NewRedisAccess ¶
func NewRedisAccess(opts ...redisoptions) *RedisAccess
NewRedisAccess 生成新的 Redis 管理器
func (*RedisAccess) GetConn ¶
func (access *RedisAccess) GetConn() *RedisHandleModel
GetConn 获取一个可用的 Redis 连接 使用完后应调用 defer conn.Close() 将连接放回池中
type RedisHandleModel ¶
type RedisHandleModel struct {
*redis.Client
Ctx context.Context
// contains filtered or unexported fields
}
RedisHandleModel 封装了 Redis 的一些常用命令
func (*RedisHandleModel) HgetallByBytesMap ¶
func (rd *RedisHandleModel) HgetallByBytesMap(key string) (result map[string][]byte, reserr error)
HgetallByBytesMap 获取 Redis 哈希表中的所有字段和值,返回字节切片类型的 map
func (*RedisHandleModel) HgetallByInt64Map ¶
func (rd *RedisHandleModel) HgetallByInt64Map(key string) (result map[string]int64, reserr error)
HgetallByInt64Map 获取 Redis 哈希表中的所有字段和值,返回 int64 类型的 map
func (*RedisHandleModel) HgetallByStringMap ¶
func (rd *RedisHandleModel) HgetallByStringMap(key string) (result map[string]string, reserr error)
HgetallByStringMap 获取 Redis 哈希表中的所有字段和值,返回字符串类型的 map
Click to show internal directories.
Click to hide internal directories.