Documentation
¶
Overview ¶
redis包:基于Redis的分布式缓存实现 提供键值存储、哈希表操作、队列操作和事务支持
Redis是一个高性能的内存数据结构存储,支持多种数据结构 本包实现了Cache接口,提供统一的缓存操作API
主要特性: - 高性能的内存存储 - 支持持久化 - 原生队列操作支持 - 丰富的数据结构 - 事务支持(Pipeline) - 集群支持 - 分布式缓存
作者: gophertool
Index ¶
- func NewRedisClient(config config.Cache) (_interface.Cache, error)
- type RedisDb
- func (r *RedisDb) BeginTx() (_interface.Tx, error)
- func (r *RedisDb) Close()
- func (r *RedisDb) Delete(key string) error
- func (r *RedisDb) Exists(key string) (bool, error)
- func (r *RedisDb) Expire(key string, ttl time.Duration) error
- func (r *RedisDb) Get(key string) (string, error)
- func (r *RedisDb) HDel(key, field string) error
- func (r *RedisDb) HGet(key, field string) (string, error)
- func (r *RedisDb) HGetAll(key string) (map[string]string, error)
- func (r *RedisDb) HSet(key, field, value string, ttl time.Duration) error
- func (r *RedisDb) LPop(key string) (string, error)
- func (r *RedisDb) LPush(key string, value string) error
- func (r *RedisDb) Len(key string) (int64, error)
- func (r *RedisDb) Pop(key string) (string, error)
- func (r *RedisDb) PopAll(key string) ([]string, error)
- func (r *RedisDb) Push(key string, value string) error
- func (r *RedisDb) RPop(key string) (string, error)
- func (r *RedisDb) RPush(key string, value string) error
- func (r *RedisDb) Set(key string, value string, ttl time.Duration) error
- type RedisTx
- func (tx *RedisTx) Commit() error
- func (tx *RedisTx) Delete(key string) error
- func (tx *RedisTx) Expire(key string, ttl time.Duration) error
- func (tx *RedisTx) HDel(key, field string) error
- func (tx *RedisTx) HSet(key, field, value string, ttl time.Duration) error
- func (tx *RedisTx) Rollback() error
- func (tx *RedisTx) Set(key string, value string, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedisClient ¶
func NewRedisClient(config config.Cache) (_interface.Cache, error)
Types ¶
type RedisDb ¶
type RedisDb struct {
// contains filtered or unexported fields
}
RedisDb Redis缓存实现结构体
func (*RedisDb) Get ¶
Get 获取指定key的值 参数:
key - 键名
返回值:
string - 键对应的值 error - 操作错误,键不存在时返回ErrKeyNotFound
func (*RedisDb) HGet ¶
HGet 获取哈希表中指定field的值 参数:
key - 哈希表键名 field - 字段名
返回值:
string - 字段对应的值 error - 操作错误,字段不存在时返回ErrKeyNotFound
func (*RedisDb) HGetAll ¶
HGetAll 获取哈希表中所有的field和value 参数:
key - 哈希表键名
返回值:
map[string]string - 所有字段和值的映射 error - 操作错误
func (*RedisDb) HSet ¶
HSet 设置哈希表中的field-value,并设置过期时间 参数:
key - 哈希表键名 field - 字段名 value - 字段值 ttl - 过期时间
返回值:
error - 操作错误
func (*RedisDb) LPop ¶
LPop 弹出列表最左边的元素 参数:
key - 列表键名
返回值:
string - 弹出的元素值 error - 操作错误,列表为空时返回ErrKeyNotFound
func (*RedisDb) RPop ¶
RPop 弹出列表最右边的元素 参数:
key - 列表键名
返回值:
string - 弹出的元素值 error - 操作错误,列表为空时返回ErrKeyNotFound
Click to show internal directories.
Click to hide internal directories.