Redis String类型

一、对字符串操作

1)APPEND key value 向key中追加一个value

APPEND key value

summary: Append a value to a key

since: 2.0.0

3)GET key 根据key 获取 value值

summary: Get the value of a key

since: 1.0.0

 

4)GETDEL key 获取该key的value 并删除该key

summary: Get the value of a key and delete the key

since: 6.2.0

5)GETEX key [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|PERSIST]  根据key获取value 并设置key过期时间

EX seconds – 以秒为单位设置key过期时间

PX milliseconds – 以毫秒为单位设置key过期时间

summary: Get the value of a key and optionally set its expiration

since: 6.2.0

6)GETRANGE key start end 根据key获取起始位置start 结束位置end 范围内的value

summary: Get a substring of the string stored at a key

since: 2.4.0

7)GETSET key value  根据key获取前value 并且 修改key中值 value

summary: Set the string value of a key and return its old value

since: 1.0.0

8)MGET key [key ...] 获取所有给定key的值

summary: Get the values of all the given keys

since: 1.0.0

9)MSET key value [key value ...] 创建所有key-value

summary: Set multiple keys to multiple values

since: 1.0.1

10)MSETNX key value [key value ...] 设置所有key-value 但每一个key都不存在,若存在则所有key都不会被创建

summary: Set multiple keys to multiple values, only if none of the keys exist

since: 1.0.1

11)PSETEX key milliseconds value 以毫秒为单位设置key过期时间

summary: Set the value and expiration in milliseconds of a key

since: 2.6.0

12)SETEX key seconds value 设置key的过期时间秒

summary: Set the value and expiration of a key

since: 2.0.0

13)SET key value [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|KEEPTTL] [NX|XX] [GET]  创建一个key-value

EX:设置过期时间 秒

EXAT: 设置过期时间 毫秒

PXAT:设置以毫秒为单位的UNIX时间戳所对应的时间为过期时间

KEEPTTL:保留设置前指定键的生存时间

GET:返回指定键原本的值,若键不存在时返回nil

NX:key不存在时创建

XX:key存在时创建

summary: Set the string value of a key

since: 1.0.0

14)SETNX key value 创建一个key-value key不存在时创建

summary: Set the value of a key, only if the key does not exist

since: 1.0.0

15)SETRANGE key offset value 在指定偏移量开始 覆盖 value值

summary: Overwrite part of a string at key starting at the specified offset

since: 2.2.0

16)STRLEN key 返回key中对应value的长度

summary: Get the length of the value stored in a key

since: 2.2.0

17)STRALGO LCS algo-specific-argument [algo-specific-argument ...]

算法 返回最长公共子序列

summary: Run algorithms (currently LCS) against strings

since: 6.0.0

二、bitmap 位图操作

1)BITCOUNT key [start end]   统计位图中开始位置start 到结束位置end 中1的数量

summary: Count set bits in a string

since: 2.6.0

2)BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]  支持子命令和整型

GET:<type offset> 返回指定偏移量的value

SET:<type offset value> 指定偏移量的value 并返回指定前的value

INCRBY:<type offset increment> 指定偏移量的自增(正)或自减(负) 并返回偏移量自增前的value

OVERFLOW WRAP|SAT|FAIL:设置溢出行为来改变调用INCRBY指令的后序

summary: Perform arbitrary bitfield integer operations on strings

since: 3.2.0

3)BITOP operation destkey key [key ...] 对bit按位运算 与 或 非 异或 并将得到的值放到新的位图中

summary: Perform bitwise operations between strings

since: 2.6.0

BITOP or orbit bit1 bit2

 

 4)BITPOS key bit [start] [end] 返回位图中第一个被设置为1的位置

summary: Find first bit set or clear in a string

since: 2.8.7

 5)GETBIT key offset 返回key中偏移量offset处的value

summary: Returns the bit value at offset in the string value stored at key

since: 2.2.0

6)SETBIT key offset value 给指定 偏移量offset 设置 value

summary: Sets or clears the bit at offset in the string value stored at key

since: 2.2.0

 

三、数值 操作

1)DECR key 自减1

summary: Decrement the integer value of a key by one

since: 1.0.0

2)DECRBY key decrement  自增 x

DECRBY i1 x

summary: Decrement the integer value of a key by the given number

since: 1.0.0

3)INCR key  key 中 自增1 

summary: Increment the integer value of a key by one

since: 1.0.0

4)INCRBY key increment  自增 x

summary: Increment the integer value of a key by the given amount

since: 1.0.0

 5)INCRBYFLOAT key increment 将key的值 增加指定的 浮点数

summary: Increment the float value of a key by the given amount

since: 2.6.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值