Redis command details-keywords

Source: Internet
Author: User

1. del key1 key2 '''''

Add version 1.0.0.

Time Complexity: O (n) N indicates the number of keys to be removed. Remove the key of a single string. the time complexity is O (1 ). Remove keys of a single list, set, sorted set, or hash table type. The time complexity is O (M), and M is the number of elements in the above data structure.

If the deleted key does not exist, ignore it.

Return Value

Integer: Number of deleted keys



2. dump key

Add version 2.6.0.

Time Complexity: the complexity of searching for a given key is O (1), and the serialization complexity of the key is O (N * M). N is the number of Redis objects that constitute the key, M is the average size of these objects. If the serialized object is a relatively small string, the complexity is O (1 ).

Serialize the given key and return the serialized value. You can use the RESTORE command to deserialize the value into a Redis key.

Serialized values have the following features:

  • It carries a 64-bit checksum and is used to detect errors. RESTORE checks the checksum before deserialization.
  • The value encoding format is consistent with that of the RDB file.
  • The RDB version is encoded in the serialized value. If the RDB format is incompatible because of different Redis versions, Redis rejects the deserialization of this value.

Serialized values do not contain any survival time information.

Return Value

If the key does not exist, nil is returned.

Otherwise, the serialized value is returned.




3. restore key ttl serialized-value

Add version 2.6.0.

Time Complexity: the complexity of searching for a given key is O (1), and the complexity of deserializing the key is O (N * M), where N is the number of Redis objects that constitute the key, M is the average size of these objects. The deserialization complexity of a sorted set is O (N * M * log (N), because the complexity of each insertion of an ordered set is O (log (N )). If the deserialization object is a relatively small string, the complexity is O (1 ).

Deserializes a given serialized value and associates it with a given key.

The ttl parameter sets the ttl in milliseconds as the key. If the ttl is 0, no ttl is set.

Before deserialization, RESTORE checks the RDB version and data checksum of the serialized value. If the RDB version is different or the data is incomplete, the RESTORE rejects deserialization, and an error is returned.

Return Value

If deserialization succeeds, OK is returned; otherwise, an error is returned.



4. exists key

Add version 1.0.0.

Time Complexity: O (1 ).

Whether the returned key exists.

Return Value

Integer, the following integer result

  • 1. If the key exists
  • 0 if the key does not exist


5. expire key seconds

Add version 1.0.0.

Time Complexity: O (1 ).

Set the key expiration time. If the key has expired, it will be automatically deleted. The key with the expiration time set is called volatile.

You can re-update the expiration time of a key before it expires, or use the PERSIST command to delete the expiration time of a key.

In Redis versions earlier than Redis 2.1.3, the key survival time can be updated.

Note that in Redis 2.4 the expire might not be pin-point accurate, and it cocould be between zero to one seconds out. development versions of Redis fixed this bug and Redis 2.6 will feature a millisecond precision EXPIRE.

Return Value

Integer, the following integer result

  • 1. If an expiration time is set
  • 0 if no expiration time is set, or the expiration time cannot be set


6.

Related Article

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.