Documentation ¶
Index ¶
- func APPEND(key string, value interface{}) (err error)
- func BLPOP()
- func BRPOP()
- func BRPOPLPUSH()
- func DECR(key string) (res int64, err error)
- func DECRBY(key, decrement string) (res int64, err error)
- func DELKey(key string) bool
- func EXISTS(key string) bool
- func EXPIREATKey(key string, date int64) bool
- func GETRANGE(key string, start, end int64) (res string, err error)
- func GETSET(key string, value interface{}) (res string, err error)
- func Get(key string) (res string, err error)
- func GetALLKeys(matchValue string) (ksyList map[string]int)
- func GetAllKeyName() ([]interface{}, int)
- func GetKeyInfo(key string)
- func GetKeyTTL(key string) int64
- func GetKeyType(key string) string
- func HDEL(key string, fields []string) error
- func HEXISTS(key, fields string) bool
- func HGET(key, fields string) (res string, err error)
- func HGETALL(key string) map[string]string
- func HINCRBY(key, field string, increment int64) (res int64, err error)
- func HINCRBYFLOAT(key, field string, increment float64) (res float64, err error)
- func HKEYS(key string) (res []string, err error)
- func HLEN(key string) (res int64, err error)
- func HMGET(key string, fields []string) (res []string, err error)
- func HMSET(key string, values []interface{}) error
- func HSET(key, field string, value interface{}) string
- func HSETNX(key, field string, value interface{}) error
- func HashHVALS(key string) (res []string, err error)
- func INCR(key string) (res int64, err error)
- func INCRBY(key, increment string) (res int64, err error)
- func INCRBYFLOAT(key, increment float64) (res float64, err error)
- func LINDEX(key string, index int64) (res string, err error)
- func LINSERT(direction bool, key, pivot, value string) (err error)
- func LLEN(key string) (res int64, err error)
- func LPOP(key string) (res string, err error)
- func LPUSH(key string, values []interface{}) (err error)
- func LPUSHX(key string, value interface{}) (err error)
- func LRANGE(key string, start, stop int64) (res []interface{}, err error)
- func LRANGEAll(key string) []interface{}
- func LREM(key string, count int64, value interface{}) (err error)
- func LSET(key string, index int64, value interface{}) (err error)
- func LTRIM(key string, start, stop int64) (err error)
- func MGET(keys []interface{}) (res []string, err error)
- func MSET(data []interface{}) (err error)
- func MSETNX(data []interface{}) (err error)
- func PSETEX(key string, ttl int64, value interface{}) (err error)
- func RPOP(key string) (res string, err error)
- func RPOPLPUSH(key, destination string) (res string, err error)
- func RPUSH(key string, values []interface{}) (err error)
- func RPUSHX(key string, value interface{}) (err error)
- func RenameKey(key, newName string) bool
- func SADD(key string, values []interface{}) (err error)
- func SCARD(key string) (err error)
- func SDIFF(keys []string) (res []interface{}, err error)
- func SDIFFSTORE(key string, keys []string) (res []interface{}, err error)
- func SET(key string, value interface{}) (err error)
- func SETEX(key string, ttl int64, value interface{}) (err error)
- func SETNX(key string, value interface{}) (err error)
- func SETRANGE(key string, offset int64, value interface{}) (err error)
- func SINTER(keys []string) (res []interface{}, err error)
- func SINTERSTORE(key string, keys []string) (res []interface{}, err error)
- func SISMEMBER(key string, value interface{}) (resData bool, err error)
- func SMEMBERS(key string) []interface{}
- func SMEMBERSString(key string) []string
- func SMOVE(key, destination string, member interface{}) (resData bool, err error)
- func SPOP(key string) (res string, err error)
- func SRANDMEMBER(key string, count int64) (res []interface{}, err error)
- func SREM(key string, member []interface{}) (err error)
- func SREMOne(key string, member interface{}) (err error)
- func SUNION(keys []string) (res []interface{}, err error)
- func SUNIONSTORE(key string, keys []string) (res []interface{}, err error)
- func SearchKeys(matchValue string) (ksyList map[string]int)
- func StringBITCOUNT()
- func StringBITOP()
- func StringGETBIT()
- func StringSETBIT()
- func StringSTRLEN()
- func UpdateKeyTTL(key string, ttlValue int64) bool
- func ZADD(key string, values []interface{}) (err error)
- func ZCARD(key string) (res int64, err error)
- func ZCOUNT(key string, min, max int64) (res int64, err error)
- func ZINCRBY(key, member string, increment int64) (res string, err error)
- func ZINTERSTORE()
- func ZRANGE(key string, start, stop int64) (res []interface{}, err error)
- func ZRANGEALL(key string) []interface{}
- func ZRANGEBYSCORE(key string, min, max, offset, count int64) (res []interface{}, err error)
- func ZRANGEBYSCOREALL(key string) (res []interface{}, err error)
- func ZRANK(key string, member interface{}) (res int64, err error)
- func ZREM(key string, member []interface{}) (err error)
- func ZREMRANGEBYRANK(key string, start, stop int64) (err error)
- func ZREMRANGEBYSCORE(key string, min, max int64) (err error)
- func ZREVRANGE(key string, start, stop int64) (res []interface{}, err error)
- func ZREVRANGEBYSCORE(key string, min, max, offset, count int64) (res []interface{}, err error)
- func ZREVRANGEBYSCOREALL(key string) (res []interface{}, err error)
- func ZREVRANK(key string, member interface{}) (res int64, err error)
- func ZSCORE(key string, member interface{}) (res string, err error)
- func ZUNIONSTORE()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APPEND ¶
APPEND key value 如果 key 已经存在并且是一个字符串, APPEND 命令将 value 追加到 key 原来的值的末尾。 如果 key 不存在, APPEND 就简单地将给定 key 设为 value ,就像执行 SET key value 一样。
func BLPOP ¶
func BLPOP()
BLPOP key [key ...] timeout BLPOP 是列表的阻塞式(blocking)弹出原语。 它是 LPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BLPOP 命令阻塞,直到等待超时或发现可弹出元素为止。
func BRPOP ¶
func BRPOP()
BRPOP key [key ...] timeout BRPOP 是列表的阻塞式(blocking)弹出原语。 它是 RPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BRPOP 命令阻塞,直到等待超时或发现可弹出元素为止。
func BRPOPLPUSH ¶
func BRPOPLPUSH()
BRPOPLPUSH source destination timeout BRPOPLPUSH 是 RPOPLPUSH 的阻塞版本,当给定列表 source 不为空时, BRPOPLPUSH 的表现和 RPOPLPUSH 一样。 当列表 source 为空时, BRPOPLPUSH 命令将阻塞连接,直到等待超时,或有另一个客户端对 source 执行 LPUSH 或 RPUSH 命令为止。
func DECR ¶
DECR key 将 key 中储存的数字值减一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。
func GETRANGE ¶
GETRANGE key start end 返回 key 中字符串值的子字符串,字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内)。
func GETSET ¶
GETSET key value 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。 当 key 存在但不是字符串类型时,返回一个错误。
func HINCRBY ¶
HINCRBY key field increment 为哈希表 key 中的域 field 的值加上增量 increment 。 增量也可以为负数,相当于对给定域进行减法操作。 如果 key 不存在,一个新的哈希表被创建并执行 HINCRBY 命令。 如果域 field 不存在,那么在执行命令前,域的值被初始化为 0
func HINCRBYFLOAT ¶
HINCRBYFLOAT key field increment 为哈希表 key 中的域 field 加上浮点数增量 increment 。 如果哈希表中没有域 field ,那么 HINCRBYFLOAT 会先将域 field 的值设为 0 ,然后再执行加法操作。 如果键 key 不存在,那么 HINCRBYFLOAT 会先创建一个哈希表,再创建域 field ,最后再执行加法操作。
func HMSET ¶
HMSET key field value [field value ...] 新建Hash 多个field 同时将多个 field-value (域-值)对设置到哈希表 key 中。 此命令会覆盖哈希表中已存在的域。
func HSETNX ¶
HSETNX key field value 给hash追加field value 将哈希表 key 中的域 field 的值设置为 value ,当且仅当域 field 不存在。
func INCR ¶
INCR key 将 key 中储存的数字值增一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。
func INCRBYFLOAT ¶
INCRBYFLOAT key increment 为 key 中所储存的值加上浮点数增量 increment 。
func LINSERT ¶
LINSERT key BEFORE|AFTER pivot value 将值 value 插入到列表 key 当中,位于值 pivot 之前或之后。 当 pivot 不存在于列表 key 时,不执行任何操作。 当 key 不存在时, key 被视为空列表,不执行任何操作。 如果 key 不是列表类型,返回一个错误。 direction : 方向 bool true:BEFORE(前) false: AFTER(后)
func LPUSHX ¶
LPUSHX key value 将值 value 插入到列表 key 的表头,当且仅当 key 存在并且是一个列表。 和 LPUSH 命令相反,当 key 不存在时, LPUSHX 命令什么也不做。
func LREM ¶
LREM key count value 根据参数 count 的值,移除列表中与参数 value 相等的元素。 count 的值可以是以下几种: count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count 。 count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值。 count = 0 : 移除表中所有与 value 相等的值。
func LSET ¶
LSET key index value 将列表 key 下标为 index 的元素的值设置为 value 。 当 index 参数超出范围,或对一个空列表( key 不存在)进行 LSET 时,返回一个错误。
func LTRIM ¶
LTRIM key start stop 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。 举个例子,执行命令 LTRIM list 0 2 ,表示只保留列表 list 的前三个元素,其余元素全部删除。
func MGET ¶
MGET key [key ...] 返回所有(一个或多个)给定 key 的值。 如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。因此,该命令永不失败。
func MSET ¶
func MSET(data []interface{}) (err error)
MSET key value [key value ...] 同时设置一个或多个 key-value 对。 如果某个给定 key 已经存在,那么 MSET 会用新值覆盖原来的旧值,如果这不是你所希望的效果,请考虑使用 MSETNX 命令:它只会在所有给定 key 都不存在的情况下进行设置操作。 MSET 是一个原子性(atomic)操作,所有给定 key 都会在同一时间内被设置,某些给定 key 被更新而另一些给定 key 没有改变的情况,不可能发生。
func MSETNX ¶
func MSETNX(data []interface{}) (err error)
MSETNX key value [key value ...] 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在。 即使只有一个给定 key 已存在, MSETNX 也会拒绝执行所有给定 key 的设置操作。 MSETNX 是原子性的,因此它可以用作设置多个不同 key 表示不同字段(field)的唯一性逻辑对象(unique logic object),所有字段要么全被设置,要么全不被设置。
func PSETEX ¶
PSETEX key milliseconds value 这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位。
func RPOPLPUSH ¶
RPOPLPUSH source destination 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作: 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。 举个例子,你有两个列表 source 和 destination , source 列表有元素 a, b, c , destination 列表有元素 x, y, z ,执行 RPOPLPUSH source destination 之后, source 列表包含元素 a, b , destination 列表包含元素 c, x, y, z ,并且元素 c 会被返回给客户端。 如果 source 不存在,值 nil 被返回,并且不执行其他动作。 如果 source 和 destination 相同,则列表中的表尾元素被移动到表头,并返回该元素,可以把这种特殊情况视作列表的旋转(rotation)操作。
func RPUSH ¶
RPUSH key value [value ...] 将一个或多个值 value 插入到列表 key 的表尾(最右边)。 如果有多个 value 值,那么各个 value 值按从左到右的顺序依次插入到表尾:比如对一个空列表 mylist 执行 RPUSH mylist a b c ,得出的结果列表为 a b c ,等同于执行命令 RPUSH mylist a 、 RPUSH mylist b 、 RPUSH mylist c 。 新创建List 将一个或多个值 value 插入到列表 key 的表尾(最右边)。
func SDIFFSTORE ¶
SDIFFSTORE destination key [key ...] 这个命令的作用和 SDIFF 类似,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。
func SETRANGE ¶
SETRANGE key offset value 用 value 参数覆写(overwrite)给定 key 所储存的字符串值,从偏移量 offset 开始。 不存在的 key 当作空白字符串处理。
func SINTERSTORE ¶
SINTERSTORE destination key [key ...] 这个命令类似于 SINTER 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。
func SISMEMBER ¶
SISMEMBER key member 判断 member 元素是否集合 key 的成员。 返回值: 如果 member 元素是集合的成员,返回 1 。 如果 member 元素不是集合的成员,或 key 不存在,返回 0 。
func SMEMBERS ¶
func SMEMBERS(key string) []interface{}
SMEMBERS key 返回集合 key 中的所有成员。 获取Set value 返回集合 key 中的所有成员。
func SMEMBERSString ¶
func SMOVE ¶
SMOVE source destination member 将 member 元素从 source 集合移动到 destination 集合。 SMOVE 是原子性操作。 如果 source 集合不存在或不包含指定的 member 元素,则 SMOVE 命令不执行任何操作,仅返回 0 。否则, member 元素从 source 集合中被移除,并添加到 destination 集合中去。 当 destination 集合已经包含 member 元素时, SMOVE 命令只是简单地将 source 集合中的 member 元素删除。 当 source 或 destination 不是集合类型时,返回一个错误。 返回值: 成功移除,返回 1 。失败0
func SRANDMEMBER ¶
SRANDMEMBER key [count] 如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素。 如果 count 为正数,且小于集合基数,那么命令返回一个包含 count 个元素的数组,数组中的元素各不相同。如果 count 大于等于集合基数,那么返回整个集合。 如果 count 为负数,那么命令返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值。
func SUNIONSTORE ¶
SUNIONSTORE destination key [key ...] 这个命令类似于 SUNION 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。
func SearchKeys ¶
func StringBITOP ¶
func StringBITOP()
BITOP operation destkey key [key ...] 对一个或多个保存二进制位的字符串 key 进行位元操作,并将结果保存到 destkey 上。 BITOP AND destkey key [key ...] ,对一个或多个 key 求逻辑并,并将结果保存到 destkey 。 BITOP OR destkey key [key ...] ,对一个或多个 key 求逻辑或,并将结果保存到 destkey 。 BITOP XOR destkey key [key ...] ,对一个或多个 key 求逻辑异或,并将结果保存到 destkey 。 BITOP NOT destkey key ,对给定 key 求逻辑非,并将结果保存到 destkey 。
func StringGETBIT ¶
func StringGETBIT()
GETBIT key offset 对 key 所储存的字符串值,获取指定偏移量上的位(bit)。 当 offset 比字符串值的长度大,或者 key 不存在时,返回 0 。
func StringSETBIT ¶
func StringSETBIT()
SETBIT key offset value 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。 value : 位的设置或清除取决于 value 参数,可以是 0 也可以是 1 。 注意 offset 不能太大,越大key越大
func ZCOUNT ¶
ZCOUNT key min max 返回有序集 key 中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量。
func ZINCRBY ¶
ZINCRBY key increment member 为有序集 key 的成员 member 的 score 值加上增量 increment 。 可以通过传递一个负数值 increment ,让 score 减去相应的值,比如 ZINCRBY key -5 member ,就是让 member 的 score 值减去 5 。 当 key 不存在,或 member 不是 key 的成员时, ZINCRBY key increment member 等同于 ZADD key increment member 。
func ZINTERSTORE ¶
func ZINTERSTORE()
ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] 计算给定的一个或多个有序集的交集,其中给定 key 的数量必须以 numkeys 参数指定,并将该交集(结果集)储存到 destination 。 默认情况下,结果集中某个成员的 score 值是所有给定集下该成员 score 值之和.
func ZRANGEBYSCORE ¶
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] 返回有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。有序集成员按 score 值递增(从小到大)次序排列。 具有相同 score 值的成员按字典序(lexicographical order)来排列(该属性是有序集提供的,不需要额外的计算)。 可选的 LIMIT 参数指定返回结果的数量及区间(就像SQL中的 SELECT LIMIT offset, count ),注意当 offset 很大时, 定位 offset 的操作可能需要遍历整个有序集,此过程最坏复杂度为 O(N) 时间。 可选的 WITHSCORES 参数决定结果集是单单返回有序集的成员,还是将有序集成员及其 score 值一起返回。 区间及无限 min 和 max 可以是 -inf 和 +inf ,这样一来,你就可以在不知道有序集的最低和最高 score 值的情况下,使用 ZRANGEBYSCORE 这类命令。 默认情况下,区间的取值使用闭区间 (小于等于或大于等于),你也可以通过给参数前增加 ( 符号来使用可选的开区间 (小于或大于)。
func ZRANGEBYSCOREALL ¶
func ZRANK ¶
ZRANK key member 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列。 排名以 0 为底,也就是说, score 值最小的成员排名为 0 。
func ZREMRANGEBYRANK ¶
ZREMRANGEBYRANK key start stop 移除有序集 key 中,指定排名(rank)区间内的所有成员。 区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。
func ZREMRANGEBYSCORE ¶
ZREMRANGEBYSCORE key min max 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。
func ZREVRANGE ¶
ZREVRANGE key start stop [WITHSCORES] 返回有序集 key 中,指定区间内的成员。 其中成员的位置按 score 值递减(从大到小)来排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order)排列。
func ZREVRANGEBYSCORE ¶
ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] 返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order )排列。
func ZREVRANGEBYSCOREALL ¶
func ZREVRANK ¶
ZREVRANK key member 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)排序。 排名以 0 为底,也就是说, score 值最大的成员排名为 0 。 使用 ZRANK 命令可以获得成员按 score 值递增(从小到大)排列的排名。
func ZUNIONSTORE ¶
func ZUNIONSTORE()
ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] 计算给定的一个或多个有序集的并集,其中给定 key 的数量必须以 numkeys 参数指定,并将该并集(结果集)储存到 destination 。
Types ¶
This section is empty.