Documentation
¶
Overview ¶
Package redisutil 命令的使用方式参考 http://doc.redisfans.com/index.html
Index ¶
- type RedisClient
- func (rc *RedisClient) Append(key string, val interface{}) (interface{}, error)
- func (rc *RedisClient) BRPop(key string) (string, error)
- func (rc *RedisClient) DBSize() (int64, error)
- func (rc *RedisClient) DECR(key string) (int, error)
- func (rc *RedisClient) Del(key string) (int64, error)
- func (rc *RedisClient) Exists(key string) (bool, error)
- func (rc *RedisClient) Expire(key string, timeOutSeconds int64) (int64, error)
- func (rc *RedisClient) FlushDB()
- func (rc *RedisClient) Get(key string) (string, error)
- func (rc *RedisClient) GetConn() redis.Conn
- func (rc *RedisClient) GetObj(key string) (interface{}, error)
- func (rc *RedisClient) HDel(args ...interface{}) (int64, error)
- func (rc *RedisClient) HGet(hashID string, field string) (string, error)
- func (rc *RedisClient) HGetAll(hashID string) (map[string]string, error)
- func (rc *RedisClient) HLen(key string) (int64, error)
- func (rc *RedisClient) HSet(hashID string, field string, val string) error
- func (rc *RedisClient) HSetNX(key, field, value string) (interface{}, error)
- func (rc *RedisClient) HVals(key string) (interface{}, error)
- func (rc *RedisClient) INCR(key string) (int, error)
- func (rc *RedisClient) LPush(key string, val string) (int64, error)
- func (rc *RedisClient) SAdd(args ...interface{}) (int64, error)
- func (rc *RedisClient) SCard(key string) (int64, error)
- func (rc *RedisClient) SPop(key string) (string, error)
- func (rc *RedisClient) SRandMember(args ...interface{}) (string, error)
- func (rc *RedisClient) SRem(args ...interface{}) (string, error)
- func (rc *RedisClient) Set(key string, val interface{}) (interface{}, error)
- func (rc *RedisClient) SetNX(key, value string) (interface{}, error)
- func (rc *RedisClient) SetWithExpire(key string, val interface{}, timeOutSeconds int64) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisClient ¶
type RedisClient struct { Address string // contains filtered or unexported fields }
func GetRedisClient ¶
func GetRedisClient(address string) *RedisClient
GetRedisClient 获取指定Address的RedisClient
func (*RedisClient) Append ¶
func (rc *RedisClient) Append(key string, val interface{}) (interface{}, error)
Append 如果 key 已经存在并且是一个字符串, APPEND 命令将 value 追加到 key 原来的值的末尾。 如果 key 不存在, APPEND 就简单地将给定 key 设为 value ,就像执行 SET key value 一样。
func (*RedisClient) BRPop ¶
func (rc *RedisClient) BRPop(key string) (string, error)
BRPop 删除,并获得该列表中的最后一个元素,或阻塞,直到有一个可用
func (*RedisClient) DECR ¶
func (rc *RedisClient) DECR(key string) (int, error)
DECR 对存储在指定key的数值执行原子的减1操作
func (*RedisClient) Exists ¶
func (rc *RedisClient) Exists(key string) (bool, error)
Exists 检查指定key是否存在
func (*RedisClient) Expire ¶
func (rc *RedisClient) Expire(key string, timeOutSeconds int64) (int64, error)
Expire 设置指定key的过期时间
func (*RedisClient) Get ¶
func (rc *RedisClient) Get(key string) (string, error)
Get 获取指定key的内容, string
func (*RedisClient) GetConn ¶
func (rc *RedisClient) GetConn() redis.Conn
GetConn 返回一个从连接池获取的redis连接, 需要手动释放redis连接
func (*RedisClient) GetObj ¶
func (rc *RedisClient) GetObj(key string) (interface{}, error)
GetObj 获取指定key的内容, interface{}
func (*RedisClient) HDel ¶
func (rc *RedisClient) HDel(args ...interface{}) (int64, error)
HDel 设置指定hashset的内容, 如果field不存在, 该操作无效, 返回0
func (*RedisClient) HGet ¶
func (rc *RedisClient) HGet(hashID string, field string) (string, error)
HGet 获取指定hashset的内容
func (*RedisClient) HGetAll ¶
func (rc *RedisClient) HGetAll(hashID string) (map[string]string, error)
HGetAll 获取指定hashset的所有内容
func (*RedisClient) HLen ¶
func (rc *RedisClient) HLen(key string) (int64, error)
HLen 返回哈希表 key 中域的数量, 当 key 不存在时,返回0
func (*RedisClient) HSet ¶
func (rc *RedisClient) HSet(hashID string, field string, val string) error
HSet 设置指定hashset的内容
func (*RedisClient) HSetNX ¶
func (rc *RedisClient) HSetNX(key, field, value string) (interface{}, error)
HSetNX 设置指定hashset的内容, 如果field不存在, 该操作无效
func (*RedisClient) HVals ¶
func (rc *RedisClient) HVals(key string) (interface{}, error)
HVals 返回哈希表 key 中所有域的值, 当 key 不存在时,返回空
func (*RedisClient) INCR ¶
func (rc *RedisClient) INCR(key string) (int, error)
INCR 对存储在指定key的数值执行原子的加1操作
func (*RedisClient) LPush ¶
func (rc *RedisClient) LPush(key string, val string) (int64, error)
LPush 将所有指定的值插入到存于 key 的列表的头部
func (*RedisClient) SAdd ¶
func (rc *RedisClient) SAdd(args ...interface{}) (int64, error)
SAdd 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略。 假如 key 不存在,则创建一个只包含 member 元素作成员的集合。
func (*RedisClient) SCard ¶
func (rc *RedisClient) SCard(key string) (int64, error)
SCard 返回集合 key 的基数(集合中元素的数量)。 返回值: 集合的基数。 当 key 不存在时,返回 0
func (*RedisClient) SPop ¶
func (rc *RedisClient) SPop(key string) (string, error)
SPop 移除并返回集合中的一个随机元素。 如果只想获取一个随机元素,但不想该元素从集合中被移除的话,可以使用 SRANDMEMBER 命令。
func (*RedisClient) SRandMember ¶
func (rc *RedisClient) SRandMember(args ...interface{}) (string, error)
SRandMember 如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素。 该操作和 SPOP 相似,但 SPOP 将随机元素从集合中移除并返回,而 SRANDMEMBER 则仅仅返回随机元素,而不对集合进行任何改动。
func (*RedisClient) SRem ¶
func (rc *RedisClient) SRem(args ...interface{}) (string, error)
SRem 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略。 当 key 不是集合类型,返回一个错误。 在 Redis 2.4 版本以前, SREM 只接受单个 member 值。
func (*RedisClient) Set ¶
func (rc *RedisClient) Set(key string, val interface{}) (interface{}, error)
Set 设置指定Key/Value
func (*RedisClient) SetNX ¶
func (rc *RedisClient) SetNX(key, value string) (interface{}, error)
SetNX 将 key 的值设为 value ,当且仅当 key 不存在。 若给定的 key 已经存在,则 SETNX 不做任何动作。 成功返回1, 失败返回0
func (*RedisClient) SetWithExpire ¶
func (rc *RedisClient) SetWithExpire(key string, val interface{}, timeOutSeconds int64) (interface{}, error)
SetWithExpire 设置指定key的内容