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-key value operation

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

Share

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

Next, there are some commonly used redis commands to learn, but some of them are disabled in our production environment, which will affect performance and do not meet the redis development specifications. You can search Ali redis development specifications for reference and study.

1Query the common keys of pattern.

In redis, fuzzy query key is allowed

There are three wildcards,?, []

: with any number of characters

?: with a single character

[]: a character in parentheses

127.0.0.1 purl 6379 > keys

1) "What"

127.0.0.1 purl 6379 > keys What

1) "What"

127.0.0.1 purl 6379 > get What

"laoyang"

127.0.0.1 purl 6379 > keys Wha

1) "What"

127.0.0.1 6379 > keys Wha [ty]

1) "What"

127.0.0.1 6379 > keys Wha?

1) "What"

2 the key key returns the random name of the

127.0.0.1 purl 6379 > set chief yuhao

OK

127.0.0.1 purl 6379 > randomkey

"chief"

127.0.0.1 purl 6379 > randomkey

"What"

3. Judge the type of key

127.0.0.1 purl 6379 > type chief

String

4. Judge whether key exists.

127.0.0.1 purl 6379 > exists chief

(integer) 1

Return 1 means it exists, 0 means it doesn't exist.

5,rename key

If key exists, the cover key will be overwritten

6 move key to move a key to another library

127.0.0.1 purl 6379 > keys

1) "yuhao"

2) "What"

127.0.0.1 move yuhao 6379 > 1

(integer) 1

127.0.0.1 purl 6379 > get yuhao

(nil)

127.0.0.1 purl 6379 > keys

1) "What"

7, expiration time-in seconds

Query validity period

127.0.0.1 purl 6379 > ttl What

(integer)-1 permanent validity is negative one

127.0.0.1 purl 6379 > get What

"laoyang"

127.0.0.1 expire What 6379 > set expiration for 5 seconds

(integer) 1

127.0.0.1 purl 6379 > get What

(nil)

127.0.0.1 6379 > keys *

(empty list or set)

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