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 common syntax commands

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Chinese document: http://redis.cn/commands.html

Redis common syntax commands

1 set key

Set key value

For example:

Set name "s_jun"

Set up multiple key value

Mset name "s_jun" age 19 sex man

Set the expiration time of key (ex: in seconds)

Set game 'DNF' ex 5

Take a value

Get key (take a single value) or mget key1 key2...key9 (take multiple values)

2 delete key

Del key1 key2....

Del name age sex

3 rename key

Rename key newkey

If the value of newkey already exists, the original value of newkey is overwritten

Renamenx key newkey

Return 1 when modification occurs, and 0 if no modification occurs

4 move key to another database (default is 0-15 databases, default is database 0)

Move key db

Move key to game to database 2

Move game 2

Move to database 2

Select 2

5 flushdb clear the key in the database where it is located

Flushdb

6 matching character

*: match any number of characters

?: with a single character

[]: a character in parentheses

Randomkey returns random key

Exists key determines whether key exists or returns 1thumb 0.

The type of value that type key returns key stores is string link set order set hash.

Ttl key queries the lifecycle of key

The expire key integer value sets the life cycle of the key

Pexpire key milliseconds, set lifecycle

Pttl key, which returns the life cycle in milliseconds

Persist key sets the specified key to be permanent

Get and return the old value and set the new value

127.0.0.1 6379 > getset age 20 # (new value)

"10" # (previously set value)

Accumulate sequentially

Incrby key value (value must be × × ×)

For example:

127.0.0.1Plus 6379 > incrby xx 1 (the following values can be understood as accumulated values in turn)

(integer) 2

Incrbyfloat xxa 1.1 (decimal)

Decreasing in turn

127.0.0.1 6379 > set age 10

OK

127.0.0.1 6379 > decr age # (minus 1)

(integer) 9

Decrby age decrease (specify decrement value)

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