This is the 9th day of my participation in the August More Text Challenge. For details, see:August is more challenging”

🎃 1, keys

Syntax: keys pattern

Function: Find all keys that match the pattern. Pattern can use wildcard characters.

Wild card:

1) * : indicates 0 or multiple characters. For example, keys * is used to query all keys.

2)? : indicates a single character, for example, wo? D, match word, wood

3) [] : a character in [] is selected. For example, wo[or]d matches word and wood, but does not match wold and woord

🎄 2, the Exists

Exists key [key…]

Function: Determines whether the key exists

Return value: integer, 1 for key and 0 for others. With multiple keys, return the number of existing keys

🎋 3, move

Syntax: move key DB

Function: Move a key to the specified database. The moved key is deleted from the original database.

Return value: 1 on success, 0 on failure

🎍 4, TTL

Syntax: TTL key

Function: Displays the TTL (time to live) of the key, in seconds.

The return value:

1) -1: The lifetime of the key is not set and the key will never expire.

2) -2: The key does not exist

🎀 5, expire

Syntax: expire key seconds

Function: Sets the lifetime of a key. When the lifetime exceeds, the key is automatically deleted. The unit is seconds.

Return value: The number 1 is returned on success, or 0 otherwise.

🎁 6, type

Syntax: type key

Function: View the data type of the value stored by the key

Return value: the data type represented by the string

1) None (key does not exist)

2) String (string)

3) List

4) Set

5) Zset

6) Hash table

🎨 7, rename

Syntax: rename key newkey

Function: Change the name of key to newkey. Returns an error if the key is the same as newKey, or if the key does not exist.

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

💎 8, del

Syntax: del key [key…]

Function: Deletes existing keys and ignores non-existent keys.

Return value: number, number of deleted keys.