rediscmd

package
v0.0.0-...-67d91c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APPEND

func APPEND(key string, value interface{}) (err error)

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

func DECR(key string) (res int64, err error)

DECR key 将 key 中储存的数字值减一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。

func DECRBY

func DECRBY(key, decrement string) (res int64, err error)

DECRBY key decrement 将 key 所储存的值减去减量 decrement 。

func DELKey

func DELKey(key string) bool

删除key

func EXISTS

func EXISTS(key string) bool

EXISTSKey 检查给定 key 是否存在。

func EXPIREATKey

func EXPIREATKey(key string, date int64) bool

指定key多久过期 接收的是unix时间戳

func GETRANGE

func GETRANGE(key string, start, end int64) (res string, err error)

GETRANGE key start end 返回 key 中字符串值的子字符串,字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内)。

func GETSET

func GETSET(key string, value interface{}) (res string, err error)

GETSET key value 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。 当 key 存在但不是字符串类型时,返回一个错误。

func Get

func Get(key string) (res string, err error)

获取String value

func GetALLKeys

func GetALLKeys(matchValue string) (ksyList map[string]int)

获取所有的key

func GetAllKeyName

func GetAllKeyName() ([]interface{}, int)

获取所有key name 返回切片

func GetKeyInfo

func GetKeyInfo(key string)

获取key的信息

func GetKeyTTL

func GetKeyTTL(key string) int64

GetKeyTTL 获取key的过期时间

func GetKeyType

func GetKeyType(key string) string

GetKeyType 获取key的类型

func HDEL

func HDEL(key string, fields []string) error

HDEL key field [field ...] 删除哈希表 key 中的一个或多个指定域,不存在的域将被忽略。

func HEXISTS

func HEXISTS(key, fields string) bool

HEXISTS key field 查看哈希表 key 中,给定域 field 是否存在。

func HGET

func HGET(key, fields string) (res string, err error)

HGET key field 返回哈希表 key 中给定域 field 的值。

func HGETALL

func HGETALL(key string) map[string]string

获取Hash value

func HINCRBY

func HINCRBY(key, field string, increment int64) (res int64, err error)

HINCRBY key field increment 为哈希表 key 中的域 field 的值加上增量 increment 。 增量也可以为负数,相当于对给定域进行减法操作。 如果 key 不存在,一个新的哈希表被创建并执行 HINCRBY 命令。 如果域 field 不存在,那么在执行命令前,域的值被初始化为 0

func HINCRBYFLOAT

func HINCRBYFLOAT(key, field string, increment float64) (res float64, err error)

HINCRBYFLOAT key field increment 为哈希表 key 中的域 field 加上浮点数增量 increment 。 如果哈希表中没有域 field ,那么 HINCRBYFLOAT 会先将域 field 的值设为 0 ,然后再执行加法操作。 如果键 key 不存在,那么 HINCRBYFLOAT 会先创建一个哈希表,再创建域 field ,最后再执行加法操作。

func HKEYS

func HKEYS(key string) (res []string, err error)

HKEYS key 返回哈希表 key 中的所有域。

func HLEN

func HLEN(key string) (res int64, err error)

HLEN key 返回哈希表 key 中域的数量。

func HMGET

func HMGET(key string, fields []string) (res []string, err error)

HMGET key field [field ...] 返回哈希表 key 中,一个或多个给定域的值。 如果给定的域不存在于哈希表,那么返回一个 nil 值。

func HMSET

func HMSET(key string, values []interface{}) error

HMSET key field value [field value ...] 新建Hash 多个field 同时将多个 field-value (域-值)对设置到哈希表 key 中。 此命令会覆盖哈希表中已存在的域。

func HSET

func HSET(key, field string, value interface{}) string

新建Hash 单个field 如果 key 不存在,一个新的哈希表被创建并进行 HSET 操作。 如果域 field 已经存在于哈希表中,旧值将被覆盖。

func HSETNX

func HSETNX(key, field string, value interface{}) error

HSETNX key field value 给hash追加field value 将哈希表 key 中的域 field 的值设置为 value ,当且仅当域 field 不存在。

func HashHVALS

func HashHVALS(key string) (res []string, err error)

HVALS key 返回哈希表 key 中所有域的值。

func INCR

func INCR(key string) (res int64, err error)

INCR key 将 key 中储存的数字值增一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。

func INCRBY

func INCRBY(key, increment string) (res int64, err error)

INCRBY key increment 将 key 所储存的值加上增量 increment 。

func INCRBYFLOAT

func INCRBYFLOAT(key, increment float64) (res float64, err error)

INCRBYFLOAT key increment 为 key 中所储存的值加上浮点数增量 increment 。

func LINDEX

func LINDEX(key string, index int64) (res string, err error)

LINDEX key index 返回列表 key 中,下标为 index 的元素。

func LINSERT

func LINSERT(direction bool, key, pivot, value string) (err error)

LINSERT key BEFORE|AFTER pivot value 将值 value 插入到列表 key 当中,位于值 pivot 之前或之后。 当 pivot 不存在于列表 key 时,不执行任何操作。 当 key 不存在时, key 被视为空列表,不执行任何操作。 如果 key 不是列表类型,返回一个错误。 direction : 方向 bool true:BEFORE(前) false: AFTER(后)

func LLEN

func LLEN(key string) (res int64, err error)

LLEN key 返回列表 key 的长度。 如果 key 不存在,则 key 被解释为一个空列表,返回 0 .

func LPOP

func LPOP(key string) (res string, err error)

LPOP key 移除并返回列表 key 的头元素。

func LPUSH

func LPUSH(key string, values []interface{}) (err error)

新创建list 将一个或多个值 value 插入到列表 key 的表头

func LPUSHX

func LPUSHX(key string, value interface{}) (err error)

LPUSHX key value 将值 value 插入到列表 key 的表头,当且仅当 key 存在并且是一个列表。 和 LPUSH 命令相反,当 key 不存在时, LPUSHX 命令什么也不做。

func LRANGE

func LRANGE(key string, start, stop int64) (res []interface{}, err error)

LRANGE key start stop 返回列表 key 中指定区间内的元素,区间以偏移量 start 和 stop 指定。

func LRANGEAll

func LRANGEAll(key string) []interface{}

获取List value

func LREM

func LREM(key string, count int64, value interface{}) (err error)

LREM key count value 根据参数 count 的值,移除列表中与参数 value 相等的元素。 count 的值可以是以下几种: count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count 。 count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值。 count = 0 : 移除表中所有与 value 相等的值。

func LSET

func LSET(key string, index int64, value interface{}) (err error)

LSET key index value 将列表 key 下标为 index 的元素的值设置为 value 。 当 index 参数超出范围,或对一个空列表( key 不存在)进行 LSET 时,返回一个错误。

func LTRIM

func LTRIM(key string, start, stop int64) (err error)

LTRIM key start stop 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。 举个例子,执行命令 LTRIM list 0 2 ,表示只保留列表 list 的前三个元素,其余元素全部删除。

func MGET

func MGET(keys []interface{}) (res []string, err error)

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

func PSETEX(key string, ttl int64, value interface{}) (err error)

PSETEX key milliseconds value 这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位。

func RPOP

func RPOP(key string) (res string, err error)

RPOP key 移除并返回列表 key 的尾元素。

func RPOPLPUSH

func RPOPLPUSH(key, destination string) (res string, err error)

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

func RPUSH(key string, values []interface{}) (err error)

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 RPUSHX

func RPUSHX(key string, value interface{}) (err error)

RPUSHX key value 将值 value 插入到列表 key 的表尾,当且仅当 key 存在并且是一个列表。

func RenameKey

func RenameKey(key, newName string) bool

修改key名称

func SADD

func SADD(key string, values []interface{}) (err error)

新创建Set 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略。

func SCARD

func SCARD(key string) (err error)

SCARD key 返回集合 key 的基数(集合中元素的数量)。

func SDIFF

func SDIFF(keys []string) (res []interface{}, err error)

SDIFF key [key ...] 返回一个集合的全部成员,该集合是所有给定集合之间的差集。 不存在的 key 被视为空集。

func SDIFFSTORE

func SDIFFSTORE(key string, keys []string) (res []interface{}, err error)

SDIFFSTORE destination key [key ...] 这个命令的作用和 SDIFF 类似,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。

func SET

func SET(key string, value interface{}) (err error)

新建String

func SETEX

func SETEX(key string, ttl int64, value interface{}) (err error)

新建String 含有时间

func SETNX

func SETNX(key string, value interface{}) (err error)

SETNX key value 将 key 的值设为 value ,当且仅当 key 不存在。 若给定的 key 已经存在,则 SETNX 不做任何动作。

func SETRANGE

func SETRANGE(key string, offset int64, value interface{}) (err error)

SETRANGE key offset value 用 value 参数覆写(overwrite)给定 key 所储存的字符串值,从偏移量 offset 开始。 不存在的 key 当作空白字符串处理。

func SINTER

func SINTER(keys []string) (res []interface{}, err error)

SINTER key [key ...] 返回一个集合的全部成员,该集合是所有给定集合的交集。 不存在的 key 被视为空集。

func SINTERSTORE

func SINTERSTORE(key string, keys []string) (res []interface{}, err error)

SINTERSTORE destination key [key ...] 这个命令类似于 SINTER 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。

func SISMEMBER

func SISMEMBER(key string, value interface{}) (resData bool, err error)

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 SMEMBERSString(key string) []string

func SMOVE

func SMOVE(key, destination string, member interface{}) (resData bool, err error)

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 SPOP

func SPOP(key string) (res string, err error)

SPOP key 移除并返回集合中的一个随机元素。

func SRANDMEMBER

func SRANDMEMBER(key string, count int64) (res []interface{}, err error)

SRANDMEMBER key [count] 如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素。 如果 count 为正数,且小于集合基数,那么命令返回一个包含 count 个元素的数组,数组中的元素各不相同。如果 count 大于等于集合基数,那么返回整个集合。 如果 count 为负数,那么命令返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值。

func SREM

func SREM(key string, member []interface{}) (err error)

SREM key member [member ...] 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略。

func SREMOne

func SREMOne(key string, member interface{}) (err error)

SREM key member [member ...] 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略。

func SUNION

func SUNION(keys []string) (res []interface{}, err error)

SUNION key [key ...] 返回一个集合的全部成员,该集合是所有给定集合的并集。

func SUNIONSTORE

func SUNIONSTORE(key string, keys []string) (res []interface{}, err error)

SUNIONSTORE destination key [key ...] 这个命令类似于 SUNION 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。

func SearchKeys

func SearchKeys(matchValue string) (ksyList map[string]int)

func StringBITCOUNT

func StringBITCOUNT()

BITCOUNT key [start] [end] 计算给定字符串中,被设置为 1 的比特位的数量。

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 StringSTRLEN

func StringSTRLEN()

STRLEN key 返回 key 所储存的字符串值的长度。 当 key 储存的不是字符串值时,返回一个错误。

func UpdateKeyTTL

func UpdateKeyTTL(key string, ttlValue int64) bool

更新key ttl

func ZADD

func ZADD(key string, values []interface{}) (err error)

新创建ZSet 将一个或多个 member 元素及其 score 值加入到有序集 key 当中。

func ZCARD

func ZCARD(key string) (res int64, err error)

ZCARD key 返回有序集 key 的基数。

func ZCOUNT

func ZCOUNT(key string, min, max int64) (res int64, err error)

ZCOUNT key min max 返回有序集 key 中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量。

func ZINCRBY

func ZINCRBY(key, member string, increment int64) (res string, err error)

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 ZRANGE

func ZRANGE(key string, start, stop int64) (res []interface{}, err error)

ZRANGE key start stop [WITHSCORES] 返回有序集 key 中,指定区间内的成员。 其中成员的位置按 score 值递增(从小到大)来排序。

func ZRANGEALL

func ZRANGEALL(key string) []interface{}

获取ZSet value 返回集合 有序集成员的列表。

func ZRANGEBYSCORE

func ZRANGEBYSCORE(key string, min, max, offset, count int64) (res []interface{}, err error)

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 ZRANGEBYSCOREALL(key string) (res []interface{}, err error)

func ZRANK

func ZRANK(key string, member interface{}) (res int64, err error)

ZRANK key member 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列。 排名以 0 为底,也就是说, score 值最小的成员排名为 0 。

func ZREM

func ZREM(key string, member []interface{}) (err error)

ZREM key member [member ...] 移除有序集 key 中的一个或多个成员,不存在的成员将被忽略。

func ZREMRANGEBYRANK

func ZREMRANGEBYRANK(key string, start, stop int64) (err error)

ZREMRANGEBYRANK key start stop 移除有序集 key 中,指定排名(rank)区间内的所有成员。 区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。

func ZREMRANGEBYSCORE

func ZREMRANGEBYSCORE(key string, min, max int64) (err error)

ZREMRANGEBYSCORE key min max 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。

func ZREVRANGE

func ZREVRANGE(key string, start, stop int64) (res []interface{}, err error)

ZREVRANGE key start stop [WITHSCORES] 返回有序集 key 中,指定区间内的成员。 其中成员的位置按 score 值递减(从大到小)来排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order)排列。

func ZREVRANGEBYSCORE

func ZREVRANGEBYSCORE(key string, min, max, offset, count int64) (res []interface{}, err error)

ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] 返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order )排列。

func ZREVRANGEBYSCOREALL

func ZREVRANGEBYSCOREALL(key string) (res []interface{}, err error)

func ZREVRANK

func ZREVRANK(key string, member interface{}) (res int64, err error)

ZREVRANK key member 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)排序。 排名以 0 为底,也就是说, score 值最大的成员排名为 0 。 使用 ZRANK 命令可以获得成员按 score 值递增(从小到大)排列的排名。

func ZSCORE

func ZSCORE(key string, member interface{}) (res string, err error)

ZSCORE key member 返回有序集 key 中,成员 member 的 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL