Home >Backend Development >C#.Net Tutorial >Redis Tutorial (12): Summary of Server Management Commands
1. Overview:
Redis was defined as a service process that runs continuously for a long time from the beginning of its design, so most system configuration parameters can take effect immediately without restarting the process. Even switching the current persistence mode from AOF to RDB does not require a restart.
In Redis, a set of commands related to server management are provided, including CONFIG SET/GET command related to parameter setting.
2. Related command list:
Command prototype | Time complexity | Command description | Return value |
CONFIGGETparameter | is mainly used to read the runtime parameters of the server, but not all configuration parameters can be read through this command. The parameters of this command accept glob-style pattern matching rules, so if the parameters contain pattern metacharacters, all matching parameters will be listed in key/value mode. If the parameter is *, then all parameters supported by the command will be listed. Finally, it should be pointed out that, unlike redis.conf, you cannot use quantity abbreviation formats, such as GB, KB, etc., in the command. Only integer values representing the number of bytes can be used. | ||
CONFIG SETparameter value | This command is used to reconfigure the runtime of the Redis server Parameters can take effect without restarting after successful setting. However, not all parameters can be dynamically set through this command. If you need to know which parameters this command supports, you can view the execution results of the CONFIG GET * command. If you want to set multiple parameters of the same type in one command, such as the save parameter in the redis.conf configuration file: save 900 1/save 300 10. In this command, we can enclose multiple key/values in double quotes and separate them with spaces, such as: config set save "900 1 300 10". | OK means the setting is successful, otherwise relevant error information will be returned. | |
CONFIG RESETSTAT | O(1) | The statistics given by the Reset INFO command. | Always returns OK. |
DBSIZE | Returns the number of Keys in the currently open database. | The number of Keys. | |
FLUSHALL | Clear all Keys in the database managed by the current server, not limited to the currently open database. | ||
##Clear all Keys in the current database |
|||
Get a series of statistics related to server health. |
|||
##Set the save strategy of RDB persistence mode |
|||
Stop all clients and perform memory data persistence in a blocking manner. If AOF mode is enabled, flush the data in the cache to the AOF file. Exit the server. Set the saving strategy of RDB persistence mode |
##SLAVEOFhost port |
||
This command is used to modify the replication settings of the SLAVE server. If a Redis server is already in the SLAVE state, the SLAVEOF NO ONE command will turn off the replicated state of the current server and at the same time switch the server to the MASTER state. The parameters of this command will specify the listening IP and port of the MASTER server. Another situation is that the current server is already the SLAVE of another MASTER. After executing this command, the current server will terminate the replication relationship with the previous MASTER and become the SLAVE of the new MASTER. The data in the previous MASTER It will also be cleared and replaced with the data in the new MASTER. However, if the SLAVEOF NO ONE command is executed on the current SLAVE server, the server will only interrupt the replication relationship with the current MASTER and upgrade to an independent MASTER, and the data in it will not be cleared. | |||
1). SLOWLOG GET N: Read command information from the slowlog queue, N represents the information of the latest N commands. 2). SLOWLOG LEN: Get the length of the slowlog queue. 3). SLOWLOG RESET: Clear the contents of slowlog. Finally, an explanation of the information returned by the SLOWLOG GET command is given. Redis 127.0.0.1:6379> Slowlog Get 10 1) 1) (Integer) 5#Unique symbol, the value is guaranteed before the redis restart. 2) (integer) 1330369320 #Command execution time expressed in Unix Timestamp format. 3) (integer) 13 #The number of microseconds used for command execution. 4) 1) "slowlog" #Output the collected commands and their parameters in the format of a string array. 2) "reset" |