In normal work, you need to perform operations on the redis database as needed.
Can refer to redis official website http://redis.io/commands for detailed understanding
1. Select to switch Databases
redis 127.0.0.1:6379[1]> HELP SELECT SELECT index summary: Change the selected database for the current connection since: 1.0.0 group: connectionredis 127.0.0.1:6379[1]> SELECT 2OK
2. llen to get the length of a list
redis 127.0.0.1:6379[2]> HELP LLEN LLEN key summary: Get the length of a list since: 1.0.0 group: listredis 127.0.0.1:6379[2]> LLEN bi(integer) 412
3. lrange obtains all elements in a list.
The lrange index starts with 0. 0 indicates the first element, and-1 indicates the last element.
redis 127.0.0.1:6379[2]> HELP LRANGE LRANGE key start stop summary: Get a range of elements from a list since: 1.0.0 group: listredis 127.0.0.1:6379[2]> LRANGE bi 0 5
4. lpush add one or more values to the beginning of a list
redis 127.0.0.1:6379[2]> HELP LPUSH LPUSH key value [value ...] summary: Prepend one or multiple values to a list since: 1.0.0 group: listredis 127.0.0.1:6379[2]> LPUSH bi http://abc.com/logUserLogin?event_id=25&uid=de721bcef5cba1fc182d18
5. rpush append one or more values to the end of a list.
redis 127.0.0.1:6379[2]> HELP RPUSH RPUSH key value [value ...] summary: Append one or multiple values to a list since: 1.0.0 group: listredis 127.0.0.1:6379[2]> RPUSH bi http://abc.com/logUserLogin?event_id=25&uid=de721bcef5cba1fc182d18
6. Save to synchronize data to the disk
The connection will be blocked when the Save command is executed, so it is best to use the bgsave command to generate the environment.
redis 127.0.0.1:6379[2]> HELP SAVE SAVE - summary: Synchronously save the dataset to disk since: 1.0.0 group: serverredis 127.0.0.1:6379[2]> SAVEOK(1.33s)
7. bgsave asynchronous data to disk
When bgsave is used, redis will save data in the background, without affecting normal client connections. redis will fork a sub-process for saving data, and the parent process will continue to process client requests.
redis 127.0.0.1:6379[2]> HELP BGSAVE BGSAVE - summary: Asynchronously save the dataset to disk since: 1.0.0 group: serverredis 127.0.0.1:6379[2]> BGSAVEBackground saving started
8. type determines the type of a key.
redis 127.0.0.1:6379[2]> HELP TYPE TYPE key summary: Determine the type stored at key since: 1.0.0 group: genericredis 127.0.0.1:6379[2]> TYPE bilist
This article is from the "Linux SA John" blog, please be sure to keep this source http://john88wang.blog.51cto.com/2165294/1440267
Common commands for redis O & M