The following are some of the most commonly used basic commands under the Redis command line, which you can refer to for your study:
1. "Set key value" is stored in a key and value. such as: Set MyName reson
2. "Get Key" reads the value of a key.
3. "Del key" deletes a key.
4. "Del key1 key2 ... keyn" deletes more than one key. such as: Del myname1 myname2
5. "Exists key" to determine whether a key exists.
6. "Type key" to see the type of key.
7. "Rename key Keynew" renames the key name. such as: Rename MyName myname2
8. "Dbsize" To view the number of keys in the current library.
9. "Expire Key Time" Specifies the expiration of the key in seconds. such as: Expire MyName 9 (set 9 seconds after expiration)
10. "TTL key" to see how long the Redis expires, in seconds.
11. "Keys *" lists all the key names in the current library.
12. The "Key *" lists all keys in the current library that begin with the string "a".
13. "Select Db-index" selects a database, such as selecting the first database: select 0; Select the second select 1; the default is 16 databases, which can be configured in redis.conf.
14. "Flushdb" clean out all the key in the current library (the production environment requires careful operation).
15. "Flushall" clean out all the key in the library (the production environment needs to be cautious).
1, key value related commands
Keys * Remove all current key
exists name to see if n has name this key
Del name Delete key name
Expire Confirm 100 Set confirm this key100 second expires
TTL confirm gets the effective length of this key confirm
Select 0 Choose to 0 database Redis The default database is 0~15 altogether 16 databases
Move confirm 1 moves the key in the current database to another database, where you move the Confire key from the current database to 1
Persist confirm removes the expiration time for this key confirm
Randomkey randomly returns a key inside the database
Rename Key2 key3 rename Key2 to Key3
Type Key2 returns the data type of the key
2, server-related commands
Ping pong Returns whether the response is connected successfully
Echo Prints some content at the command line
Select 0~15 Numbered Database
Quit/exit Exit Client
Dbsize returns the number of key keys in the current database
Info returns information on Redis
Config get dir/* live transmit requests received
FLUSHDB Delete all keys in the currently selected database
Flushall Delete databases in all databases
1, Redis-benchmark
Redis baseline information, Redis server performance detection
Redis-benchmark-h localhost-p 6379-c 100-n 100000
100 concurrent connections, 100,000 requests, detecting Redis server performance with host localhost port 6379
[Root@architect redis-1.2.6]# redis-benchmark-h localhost-p 6379-c 100-n 100000
PING = = = = = = =
10001 requests completed in 0.41 seconds
Parallel clients
3 bytes Payload
Keep Alive:1
0.01% <= 0 milliseconds
23.09% <= 1 milliseconds
85.82% <= 2 milliseconds
95.60% <= 3 milliseconds
97.20% <= 4 milliseconds
97.96% <= 5 milliseconds
98.83% <= 6 milliseconds
99.41% <= 7 milliseconds
99.70% <= 8 milliseconds
99.99% <= 9 milliseconds
100.00% <= milliseconds
24274.27 Requests per second
2, REDIS-CLI
Redis-cli-h localhost-p 6380 Monitor
Dump all the received requests at real time;
Monitor host for localhost, port for 6380,redis connection and read and write operation
[Root@architect redis-1.2.6]# redis-cli-h localhost-p 6380 Monitor
+ok
+1289800615.808225 "Monitor"
+1289800615.839079 "Get" "name"
+1289800615.853694 "PING"
+1289800615.853783 "PING"
+1289800615.854646 "PING"
+1289800615.854974 "PING"
+1289800615.857693 "PING"
+1289800615.866862 "PING"
+1289800615.871944 "PING"
Redis-cli-h Localhost-p 6380 Info
Provide information and statistics about the server;
Provides statistics for 6380,redis service with host as localhost, port
[root@architect redis-1.2.6]# redis-cli-h localhost-p 6380 info
redis_version:2.0.4
redis_git_sha1:0 0000000
redis_git_dirty:0
arch_bits:32
multiplexing_api:epoll
process_id:21990
Uptime_in_ seconds:490580
Uptime_in_days:5
connected_clients:103
connected_slaves:0
blocked_clients:0
Used _memory:4453240
used_memory_human:4.25m
changes_since_last_save:200
bgsave_in_progress:0
Last_save _time:1290394640
bgrewriteaof_in_progress:0
total_connections_received:809
total_commands_processed : 44094018
expired_keys:0
hash_max_zipmap_entries:64
hash_max_zipmap_value:512
pubsub_channels:0
pubsub_patterns:0
vm_enabled:0
role:slave
master_host:localhost
master_port:6379
Master_ Link_status:up
master_last_io_seconds_ago:18
db0:keys=1319,expires=0
3, Redis-stat
Redis-stat Host localhost Port 6380 Overview
Print General information about a Redis instance;
Real-time print out host for localhost, port for 6380,redis instance of the overall information
[Root@architect redis-1.2.6]# redis-stat Port 6380 Overview
-------data------------------Load------------------------------Childs-
Keys USED-MEM clients requests connections
1319 5.37M 103 44108021 (+44108021) 810
1319 5.38M 103 44108124 (+103) 810
1319 5.38M 103 44108225 (+101) 810
1319 5.39M 103 44108326 (+101) 810
1319 5.40M 103 44108427 (+101) 810
1319 5.41M 103 44108528 (+101) 810
Redis-stat host localhost Port 6380 overview
Measure Redis server latency; '
The output host is localhost and the port is the response length of each request in the 6380,redis service
[Root@architect redis-1.2.6]# redis-stat Port 6380 Latency
1:0.16 ms
2:0.11 ms
3:0.15 ms
4:0.11 ms
5:0.18 ms
6:0.14 ms
Tips:redis In addition to and empty, other characters can be done as a key name, and the length does not require, but for performance, the general key name should not be set too long. It is also necessary to know that the key name of the Redis is case-sensitive.