Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the operation commands of key

Shulou Source: shulou.com Published: 2022-06-03 06:00:47 11月17日 Update

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!

Tags: Function grammar character time command data move success content unit multiple situation number quantity more knowledge type practical identical learned Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Apple MySQL vpn