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

What are the operation commands of key

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what are the operation commands of key". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Keys

*: indicates 0 or more characters, for example: keys * queries all key.

? : represents a single character, for example: wo?d, matching word, wood

[]: indicates a character within the selection [], such as wo[ or] d, which matches word and wood, but does not match wold and woord

Exists

Syntax: exists key [key...]

Function: to judge whether key exists

Return value: integer. If there is a key, it returns 1, and the other returns 0. Using multiple key, returns the number of key that exist.

Move

Syntax: move key db

Function: move the key to the specified database, and the moved key is deleted in the original database.

Return value: 1 for success and 0 for failure.

Ttl

Syntax: ttl key

Purpose: view the remaining lifetime of key (ttl: time to live) in seconds.

Return value:

-1: key's lifetime is not set, and key never expires.

-2:key does not exist

Expire

Syntax: expire key seconds

Function: set the survival time of key. If the time is exceeded, key will be deleted automatically. The unit is seconds.

Return value: the number 1 is returned if the setting is successful, and 0 in other cases.

Type

Syntax: type key

Purpose: to view the data types of values stored by key

Return value: the data type represented by the string

Rename

Syntax: rename key newkey

Function: change key to newkey. An error is returned when key and newkey are the same, or key does not exist.

When newkey already exists, the RENAME command overwrites the old value.

Del

Syntax: del key [key...]

Function: delete the existing key and ignore the non-existent key.

Return value: number, number of key deleted.

This is the end of the content of "what are the operation commands of key". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report