Redis keys Command

Source: Internet
Author: User
Tags delete key redis
First, set key, and get
172.16.9.24:6379> set name Tom
172.16.9.24:6379> gets name

Two, delete key, which is used to delete key when key exists
172.16.9.24:6379> del name

three, serialized key
172.16.9.24:6379> dump name

Four, checking for the existence
of a given key 172.16.9.24:6379> exists name

Five, set the expiration time (in seconds) for the given key
172.16.9.24:6379> expire name

Six, in seconds, Returns the remaining lifetimes of the given key
172.16.9.24:6379> TTL name

Seven, move the key of the current database to the given database db (db is from 0-15)
172.16.9.24:6379> move key db

Eight, remove key expiration time, key will persist
172.16.9.24:6379> PERSIST Key

Nine, from the current database to return a key
172.16.9.24:6379> Randomkey

10, modify the name of the key
172.16.9.24:6379> Rename key Newkey

11, only when Newkey does not exist, the key is renamed Newkey.
172.16.9.24:6379> Renamenx Key Newkey

12, returns the type of the value stored by the key.
172.16.9.24:6379> Type key

set expiration Time extension

1, the role of expireat and expire similar to the expireat command to accept the time parameter is the UNIX timestamp (Unix timestamp)
172.16.9.24:6379> expireat key timestamp< C1/>2, set the expiration time of the key in milliseconds
172.16.9.24:6379>pexpire key milliseconds

3, set key expiration time stamp (Unix timestamp) in milliseconds
172.16.9.24:6379> pexpireat Key Milliseconds-timestamp

returns the remaining time extension for a key

Returns the remaining expiration time of a key in milliseconds
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.