Redis System Management

Source: Internet
Author: User
Tags redis cluster redis server

Redis System ManagementExperiment Introduction

The previous section of the experiment described the basic data types of Redis, and this experiment continues to explain Redis-related commands and management operations.

In Redis, the command case is not sensitive.

first, suitable for all types of common commands(1) EXIT and DEL

EXISTS key determines whether a key exists; returns 1; otherwise returns 0; DEL key Deletes a key, or a series of Key;del Key1 Key2 Key3 key4. Successful return 1, Failure returns 0 (key value does not exist).

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/11/wKioL1Wwx7nDIwc0AAFsMvzrgoA490.jpg "title=" 14.png "alt=" wkiol1wwx7ndiwc0aafsmvzrgoa490.jpg "/>

(2) TYPE and KEYS

Type key: Returns the data type of a key element (none: Not present, string: Character, List,set,zset,hash), key does not exist return null. Keys Key-pattern: Returns a list of matching keys (keys foo*: Keys to find the beginning of foo)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/14/wKiom1WwxefRPHXlAAK2fiwWG5g885.jpg "title=" 15.png "alt=" wkiom1wwxefrphxlaak2fiwwg5g885.jpg "/>

(3) Randomkey and CLEAR

Randomkey: Randomly obtains a key that already exists and returns an empty string if the current database is empty

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/11/wKioL1Wwx9zxxXNjAAEqxi5vngU915.jpg "title=" 16.png "alt=" wkiol1wwx9zxxxnjaaeqxi5vngu915.jpg "/>

(4) RENAME and Renamenx

RENAME oldname newname: Changed key name, new key if present will be overwritten Renamenx oldname newname: Change key name, if name exists then change failed

The author Randomkey The result for mylist, renaming this key value to NewList.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/14/wKiom1WwxgKh1nT8AAHX886v3ns433.jpg "title=" 17.png "alt=" wkiom1wwxgkh1nt8aahx886v3ns433.jpg "/>

(5) Dbsize

Dbsize: Returns the total number of keys for the current database

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/11/wKioL1Wwx_KQu_5KAACecsVDsDQ281.jpg "title=" 18.png "Width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:500px;height:140px; "alt=" wkiol1wwx_kqu_ 5kaacecsvdsdq281.jpg "/>

Second, Redis time-related commands(1) Limit the key time to live

This is also a command that ignores data types and is useful for temporary storage. Avoid a large number of Del operations.

EXPIRE: Set the expiration time of a key (in seconds), (EXPIRE Bruce 1000: Set Bruce this key1000 seconds after the system is automatically deleted) Note: If the value has been changed since it has not expired, then that value will be cleared. 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/70/14/wKiom1WwxhfTmgqAAAGDp6m0x_Y185.jpg "title=" 19.png "alt=" wkiom1wwxhftmgqaaagdp6m0x_y185.jpg "/>

The result shows that after executing the expire command, the get is immediately displayed and the key exists. After 10 seconds, the key has been automatically deleted.

(2) Query key remaining time to live

The time-limited operation can be implemented in the set command again, and the TTL command is used to query the remaining lifetime of the key. TTL: How long does it look for a key to expire, return seconds

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/11/wKioL1WwyAfAUX4TAAF47J0gcD4830.jpg "title=" 20.png "alt=" wkiol1wwyafaux4taaf47j0gcd4830.jpg "/>

(3) Clear key

FLUSHDB: Empties all keys in the current database

Flushall: Clears all keys from all databases

iii. redis Settings Related commands

Redis has its own configuration file that can be viewed or changed through the Client-command window. The relevant commands are described below:

(1) config GET and config SET

Config GET: Used to read configuration parameters for running Redis server. Config SET: Used to change configuration parameters for running Redis server. AUTH: An example of a redis password under the authentication password:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/14/wKiom1WwxirwNwDSAAK5kGT_ThU636.jpg "title=" 21.png "alt=" wkiom1wwxirwnwdsaak5kgt_thu636.jpg "/>

The result shows that at the beginning of the Reids did not set the password, the password query results are empty. Then set the password to test123, again query error. After auth command authentication, can be queried normally.

You can change the password by modifying the Redis configuration file redis.conf.

The CONFIG get command is displayed with the key-value of the list, such as the maximum entry for the query data type:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/11/wKioL1WwyBmRHtwSAAHtB-Xn9J4024.jpg "title=" 22.png "alt=" wkiol1wwybmrhtwsaahtb-xn9j4024.jpg "/>

(2) Reset report

CONFIG Resetstat: Resets the data statistics report, usually returning a value of ' OK '.

Iv. Inquiry Information

info [section]: Query Redis related information. The info command can query almost all redis information, with the following command options:

1. General information for Server:redis server

2. connection options for Clients:client

3. Memory: Information about storage usage

4. Persistence:rdb and AOF related information

5. Stats: General statistics

6. Replication:master/slave Request Information

7. cpu:cpu occupancy Information Statistics

8. Cluster:redis Cluster information

9. keyspace: Database Information Statistics

All: return all information

Default: Return general settings Information

If the command argument is empty, the info command returns all information.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/14/wKiom1WwxjzBkvc0AAPjTUiQO5Q750.jpg "title=" 23.png "alt=" wkiom1wwxjzbkvc0aapjtuiqo5q750.jpg "/>

Reference Documents

Http://redis.io/commands/config-resetstat


Redis System Management

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.