Beckham _ redis key value learning, Beckham _ rediskey key value

Source: Internet
Author: User

Beckham _ redis key value learning, Beckham _ rediskey key value

Redis General (key) Type

1. What is a general key type?

2. View General commands

Iii. General examples

 

 

 

 

I. general type

It is literally translated from the word generic, so it is called the general type or attribute type. Redis is a key-value database, so it can be understood as key-specific operation instructions.

 

2. View General commands

127.0.0.1: 6379> help @ generic

 

DELkey [key...]

Summary: Delete a key

Since: 1.0.0

 

DUMP key

Summary: Return a serialized version of the value stored at thespecified key.

 

Since: 2.6.0

 

EXISTS key

Summary: Determine if a key exists

Since: 1.0.0

........

 

Iii. General examples

1. General commands

Name

Format

Description

Del

Del key key1...

Removes one or more given keys.

If the key does not exist, ignore this command.

Keys

Keys *

Search for keys in the specified mode

Randomkey

Randomkey

Returns (does not delete) a random key from the current database.

Ttl

Ttl key

Returns the time to live (in seconds) of the given key ). If-1 is returned, the key does not have a life time set.

Exists

Exists key

Check whether the given key exists. If yes, 1 is returned. Otherwise, 0 is returned.

Move

Move key db

Move the key of the current database (0 by default) to the given database. If the current database (source database) and the given database (target database) have a given key with the same name, or the key does not exist in the current database, moving does not work.

Rename

Rename key newkey

If the key and newkey are the same or do not exist, an error is returned. When newkey already exists, the rename Command overwrites the old value.

Type

Type key

Return the type of the value stored in the key.

Expire

Expire key seconds

Set the survival time for the given key.

When the key expires, it is automatically deleted.

Renamenx

Renamenx key newkey

If newkey does not exist, change the key to newkey.

Expireat

Expireat key timestamp

Set the survival time for the key. The time is the unconfirmed timestamp.

Persist

Persist key

Remove the survival time of a given key

Sort

Sort key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern...] [ASC | DESC] [ALPHA] [STORE destination]

Returns or stores the sorted elements in the given list, set, and sorted set key. By default, numbers are used as objects for sorting. Values are interpreted as double-precision floating-point numbers and then compared.

 

2. view all current keys

127.0.0.1: 6379> keys *

1) "name"

3. view the key type

127.0.0.1: 6379> type name

String

4. delete key

127.0.0.1: 6379> del name

(Integer) 1

127.0.0.1: 6379> keys *

(Empty list or set)

5. Set the key time

127.0.0.1: 6379> set name xiaobei

OK

127.0.0.1: 6379> expire name 10

(Integer) 1

127.0.0.1: 6379> get name

"Xiaobei"

127.0.0.1: 6379> ttl name

(Integer)-2

127.0.0.1: 6379> get name

(Nil)

6. time when the key is removed

127.0.0.1: 6379> set name xiaobei

OK

127.0.0.1: 6379> expire name 3600

(Integer) 1

127.0.0.1: 6379> ttl name

(Integer) 3596

127.0.0.1: 6379> persist name

(Integer) 1

127.0.0.1: 6379> ttl name

(Integer)-1

127.0.0.1: 6379> get name

"Xiaobei"

 

7. Determine whether the key exists

127.0.0.1: 6379> exists name

(Integer) 1

127.0.0.1: 6379> exists name1

(Integer) 0

 

8. Rename the key

127.0.0.1: 6379> rename name name1

OK

127.0.0.1: 6379> keys *

1) "name1"

 

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.