[Redis] redis command Summary (2), redis command Summary

Source: Internet
Author: User
Tags echo message

[Redis] redis command Summary (2), redis command Summary
Publish/subscribe pub/sub

Command Format

Time Complexity

Command description

Return Value

Publish channel message

O (N)

Sends the message to the specified channel.

Number of subscribers who receive the message

Subscribe channel [channel...]

O (N)

Subscribe to the information of a given Channel

 

Psubscribe pattern [pattern...]

O (N)

Subscribe to a channel in the specified mode

 

Unsubscribe channel [channel...]

O (N)

Unsubscribe to a specified channel

 

Punsubscribe pattern [pattern...]

O (N)

Unsubscribe to a channel in the specified mode

 

Transaction

Command Format

Time Complexity

Command description

Return Value

Watch

Key [key...]

O (1)

Monitors one or more keys. If the key is changed by other commands before the transaction is executed, the transaction will be interrupted.

Always OK

Unwatch

O (1)

Disable the watch command to monitor all keys

Always OK

Multi

O (1)

Mark the start of a transaction block. Multiple commands in the transaction block will be put into a queue in sequence, and finally executed atomically by the exec command

Always OK

Discard

O (1)

Cancel the transaction and discard all commands in the transaction block.

Always OK

Exec

O (N)

Execute commands in all transaction Blocks

When the operation is interrupted, the null value nil is returned.

 

Script

 

Command Format

Time Complexity

Command description

Return Value

Eval script

Numkeys

Key [key...]

Arg [arg...]

Depends on the situation

Execute a lua script

 

Evalsha sha1

Numkeys

Key [key...]

Arg [arg...]

Depends on the situation

Evaluate the scripts cached on the server based on the given shal verification code.

You can use the script load command to cache scripts to the server. Other places of this command, such as the parameter input method, are the same as the eval command.

 

Script exists

Script [script...]

O (N)

Check whether the script exists in the cache and does not understand the execution.

1 exists, 0 does not exist

Script flush

O (N)

Delete all scripts in the script Cache

Always Return OK

Script kill

O (1)

Terminate the currently executed script. This command takes effect only when the script has not executed any write operations.

Success OK, failed: Error Code

Script load script

O (N)

Load the specified lua script to the script cache.

Sha1 checksum of the given script

 

Connection

Command Format

Command description

Return Value

Auth password

The server verifies the given password.

Get the password through get config requirepass

 

Ping

Check whether the server is running

Pong is returned successfully.

Select index

Switch to the given database. Database 0 is used by default.

 

Echo message

Print the given string, which is used for testing

 

Quit

Close current connection

 

 

Server

Command Format

Time Complexity

Command description

Return Value

Time

O (1)

Returns the current server time.

The first string is the current timestamp.

The second string is the number of milliseconds that have elapsed in the first second.

Dbsize

O (1)

Returns the number of keys of the current database.

Quantity

Bgrewriteaof

O (N)

Asynchronously rewrite the aof file in the background to reflect the status of the current database

Feedback

Bgsave

O (N)

Asynchronously saves the data of the current database to the disk in the background.

The client can use the LASTSAVE command to view related information and determine whether the BGSAVE command is successfully executed.

Feedback

Save

O (N)

Synchronously Save the data of the current database to the disk

OK is returned when the storage is successful.

Lastsave

O (1)

Returns the last timestamp when redis successfully saved the data to the disk.

A unix Timestamp

Slaveof host port

O (n)

O (1)

Dynamically modify the replication function when redis is running.

You can change the current server to the slave server of the specified server.

If the current server is already a slave server of a master server, running the slaveof host port will stop the current server from synchronizing the old master server and discard the old dataset, in turn, start to synchronize the new master server. O (n)

If the command slaveof no one is executed on a slave server, the slave server will disable the replication function and switch from the slave server to the master server. The original synchronized dataset will not be discarded. O (1)

Always Return OK

Flushall

 

Clear the data of the entire redis server (delete all keys of all databases)

Always Return OK

Flushdb

O (1)

Clear all keys in the current database

Always Return OK

Shutdown

 

Stop all clients

An error is returned when execution fails.

When the execution is successful, no information is returned. The connection between the server and the client is disconnected, and the client automatically exits.

Slowlog

Subcommand

[Argument]

 

Manage redis slow query logs

 

Info [section]

O (1)

Returns information about the redis server.

 

Config get

Parameter

 

Get the Configuration Parameter Value

 

Config set

Parameter value

 

Set the configuration parameter to a specified value.

If the setting is successful, OK is returned. Otherwise, an error is returned.

Config resetstat

O (1)

Reset some statistics in the info command

Always Return OK

Debug object key

O (1)

Obtain key debugging information

 

Debug segfault

 

Execute an invalid memory access. This means that the redis server crashes and is only used for debugging simulation during development.

 

Monitor

 

Prints the commands received by the redis server in real time.

Always Return OK

Sync

 

Internal commands for replication

 

Client list

O (N)

Obtains the list of connections from the client to the server.

 

Client kill ip: port

O (N)

Close the client with the ip Address: port

If the specified client exists and is closed successfully, OK is returned.

Client setname

Connection-name

O (1)

Allocate a name for the current connection

If the setting is successful, OK is returned.

Client getname

O (1)

Return the client setname command to set the connection name

If no name is set for the connection, a blank reply is returned;

If a name is set, a name is returned.

Obtains, sets, and controls client information.

Client list, client getname;

Clent kill; client setname, shutdown

Obtain the server information

Info, config get, time, dbsize

Config set, config resetstat,

Debugging

Debug object, debug setfault, monitor

Persistence

Bgrewriteaof, bgsave, save, lastsave,

Delete database key

Flushall, flushdb

Master/Slave Server Control

Slaveof


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.