Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis-string type

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1 number of seconds of px set key value ex / px millisecond nx/xx

127.0.0.1 6379 > set name z2 px 1000

OK

127.0.0.1 purl 6379 > ttl name

(integer)-2

Nx: indicates that the action is performed when the key does not exist

Xx: indicates the operation when key exists

Such as:

127.0.0.1 purl 6379 > flushdb

OK

127.0.0.1 purl 6379 > set jiaxiao dfss

OK

127.0.0.1 purl 6379 > set jiaxiao gjjx nx

(nil)

127.0.0.1 purl 6379 > get jiaxiao

"dfss"

127.0.0.1 purl 6379 > set jiaxiao hdjx xx

OK

127.0.0.1 purl 6379 > get jiaxiao

"hdjx"

2,get key

Get key value

3. Get multiple key

Mget key

4, offset character value

127.0.0.1 purl 6379 > set suixingpay niubi

OK

127.0.0.1 purl 6379 > get suixingpay

"niubi"

127.0.0.1 6379 > setrange suixingpay 2 ll

(integer) 5

127.0.0.1 purl 6379 > get suixingpay

"nilli"

Note: if offset > character length, the character automatically complements 0x00

127.0.0.1 6379 > setrange suixingpay 6 c

(integer) 7

127.0.0.1 purl 6379 > get suixingpay

"nilli\ x00c"

5, added value

127.0.0.1 6379 > append suixingpay @

(integer) 8

127.0.0.1 purl 6379 > get suixingpay

"nilli\ x00c@"

6, get the range of a value in the string

Note: for the subscript of a string, the left number starts at 0 and the right number starts at-1

127.0.0.1 purl 6379 > set area beijing

OK

127.0.0.1 getrange area 6379 > 1

"ijin"

127.0.0.1 6379 > getrange area 0-5

"bei"

7, increase or decrease

127.0.0.1 6379 > set ages 20

OK

127.0.0.1 purl 6379 > get ages

"20"

127.0.0.1 purl 6379 > incr age

(integer) 1

127.0.0.1 purl 6379 > get ages

"20"

127.0.0.1 purl 6379 > incr ages

(integer) 21

127.0.0.1 purl 6379 > get ages

"21"

127.0.0.1 purl 6379 > decr ages

(integer) 20

127.0.0.1 purl 6379 > get ages

"20"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report