Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Redis server


May 16, 2021 Redis


Table of contents


Redis server

Redis server commands are primarily used to manage redis services.

Instance

The following example shows how to get statistics for a redis server:

redis 127.0.0.1:6379> INFO

# Server
redis_version:2.8.13
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c2238b38b1edb0e2
redis_mode:standalone
os:Linux 3.5.0-48-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:3856
run_id:0e61abd297771de3fe812a3c21027732ac9f41fe
tcp_port:6379
uptime_in_seconds:11554
uptime_in_days:0
hz:10
lru_clock:16651447
config_file:

# Clients
connected_clients:1
client-longest_output_list:0
client-biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:589016
used_memory_human:575.21K
used_memory_rss:2461696
used_memory_peak:667312
used_memory_peak_human:651.67K
used_memory_lua:33792
mem_fragmentation_ratio:4.18
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:3
rdb_bgsave_in_progress:0
rdb_last_save_time:1409158561
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:24
total_commands_processed:294
instantaneous_ops_per_sec:0
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:41
keyspace_misses:82
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:264

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:10.49
used_cpu_user:4.96
used_cpu_sys_children:0.00
used_cpu_user_children:0.01

# Keyspace
db0:keys=94,expires=1,avg_ttl=41638810
db1:keys=1,expires=0,avg_ttl=0
db3:keys=1,expires=0,avg_ttl=0

Redis server command

The following table lists the commands for the redis server:

Serial number Commands and descriptions
1 BGREWRITEAOF
Perform an AOF (AppendOnly File) file rewrite asynchronously
2 BGSAVE
Save data from the current database asynchronously to disk in the background
3 CLIENT KILL [ip:port] [ID client-id]
Close the client connection
4 CLIENT LIST
Gets a list of client connections to the server
5 CLIENT GETNAME
Gets the name of the connection
6 CLIENT PAUSE timeout
The command from the client is terminated within a specified time
7 CLIENT SETNAME connection-name
Set the name of the current connection
8 CLUSTER SLOTS
Gets an array of maps of cluster nodes
9 COMMAND
Get an array of Redis command details
10 COMMAND COUNT
Gets the total number of Redis commands
11 COMMAND GETKEYS
Gets all the keys for a given command
12 TIME
Returns the current server time
13 COMMAND INFO command-name [command-name ...]
Gets an array that specifies the description of the Redis command
14 CONFIG GET parameter
Gets the value of the specified configuration parameter
15 CONFIG REWRITE
Rewrite the redis.conf profile specified when the Redis server is started
16 CONFIG SET parameter value
Modify the redis configuration parameters without restarting
17 CONFIG RESETSTAT
Reset some of the statistics in the INFO command
18 DBSIZE
Returns the number of keys for the current database
19 DEBUG OBJECT key
Gets debug information for key
20 DEBUG SEGFAULT
Let the Redis service crash
21 FLUSHALL
Delete all keys for all databases
22 FLUSHDB
Delete all keys from the current database
23 INFO [section]
Get various information and statistics for the Redis server
24 LASTSAVE
Returns the last time Redis successfully saved data to disk, in UNIX timestamp format
25 MONITOR
Print out the commands received by the Redis server in real time for debugging
26 ROLE
Returns the role to which the primary instance belongs
27 SAVE
Save data asynchronously to the hard drive
28 SHUTDOWN [NOSAVE] [SAVE]
Save data asynchronously to the hard disk and shut down the server
29 SLAVEOF host port
Turn the current server into a slave server for the specified server
30 SLOWLOG subcommand [argument]
Manage the slow logs for redis
31 SYNC
Internal commands for copying functionality