Redis for Nosql: key operation commands

Source: Internet
Author: User
1: del time complexity: the time complexity of the String type is O (1 ). Number of keys deleted from other O (N) N tables. return Value: Number of actually deleted keys Operation Command: redis127.0.0.1: 6366delmy_set_diffmy_set (integer) 22: keys Command Format: keyspattern Description: Get all keys that match the PATTERN parameter

1: del time complexity: the time complexity of the String type is O (1 ). Number of keys deleted from other O (N) N tables. return Value: Number of actually deleted keys Operation Command: redis 127.0.0.1: 6379 del my_set_diff my_set (integer) 2 2: keys Command Format: keys pattern description: Get all keys that match the PATTERN parameter

1: del
Time Complexity: the time complexity of the String type is O (1 ). Number of keys deleted from other O (N) N tables.
Return Value: number of keys actually deleted
The command is as follows:
Redis 127.0.0.1: 6379> del my_set_diff my_set
(Integer) 2

2: keys
Command Format: keys pattern
Description: obtains all the keys that match the PATTERN parameter.
Time Complexity: number of keys in the O (N) table.
Return Value: A list of keys in the matching mode.
The command is as follows:
Redis 127.0.0.1: 6379> keys my *
1) "my_set_2 ″
2) "myset2 ″
3) "myset5 ″
4) "myset"

3: exists
Description: determines whether a specified key exists. 1 exists, 0 does not exist.
Time Complexity: O (1)
The command is as follows:
Redis 127.0.0.1: 6379> exists myset
(Integer) 1
Redis 127.0.0.1: 6379> exists myset9
(Integer) 0

4: move
Command Format: move key db
Time Complexity: O (1)
Description: moves the Key specified in the current database to the database specified in the parameter.
If the Key already exists in the target database or does not exist in the current database,
This command will not perform any operation and return 0.
Return Value: 1 successful; otherwise, 0

5: rename
Command Format: rename key newkey
Time Complexity: O (1)
Description: if the key does not exist, an error is returned. If the newKey exists, it is overwritten.

6: renamenx
Command Format: renamenx key newkey
Time Complexity: O (1)
Description: This parameter is renamed only when newkey does not exist.
Return Value: 1 is returned successfully. If newkey already exists, 0 is returned.

7: persist
Command Format: persist key
Time Complexity: O (1)
Description: The survival time for removing a given key.
Return Value: 1 indicates that the Key expiration time is removed, and 0 indicates that the Key does not exist or there is no expiration time.

8: expire
Command Format: EXPIRE key seconds
Time Complexity: O (1)
Description: sets the survival time for a given key. When the key expires, it is automatically deleted.
Return Value: 1 is returned if the setting is successful. If the key does not exist or the survival time cannot be set for the key, 0 is returned.

9: expireat
Command Format: expireat key timetamp
Time Complexity: O (1)
Description: The EXPIREAT function is the same as EXPIRE. It is used to set the survival time for the key. The difference is that the time parameter accepted by the EXPIREAT command is UNIX timestamp ).
Return Value: 1 is returned if the setting is successful. If the key does not exist or the survival time cannot be set for the key, 0 is returned.

10: ttl
Command Format: ttl key
Time Complexity: O (1)
Description: returns the time to live (in seconds) of the given key ).
Return Value: The remaining survival time of the key (in seconds ). If the key does not exist or the TTL is not set,-1 is returned.
11: randomkey
Time Complexity: O (1)
Description: A random Key is returned.
Returned value: the random key returned. If the database is empty, nil is returned.

12: type
Command Format: type key
Time Complexity: O (1)
Description: gets the key type.
Return Value: string, list, set, hash, and zset are returned. If the key does not exist, none is returned.

13: dump
Command Format: dump key
Available version: reidis> = 2.6.0
Time Complexity: O (1)
Description: serialize the given key and return the serialized value. The RESTORE command can be used to deserialize the value into a Redis key.
Returned value: if the key does not exist, nli is returned; otherwise, the serialized value is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.