Redis : Basic Usage#32016/09/06 |
This is the Basic Usage of Redis with "redis-cli" client program.
Following examples are basic one, you can see more commands on Official Site below.
⇒ http://redis.io/commands |
|
[1] | This is the basic Usage of Lists. |
root@dlp:~#
redis-cli -a password # preppend Value to a List (possible to set multiple values with space) 127.0.0.1:6379> lpush list01 value01 (integer) 1 # append Value to a List (possible to set multiple values with space) 127.0.0.1:6379> rpush list01 value02 (integer) 2 # get length of a List 127.0.0.1:6379> llen list01 (integer) 2 # get specified element of a List 127.0.0.1:6379> lindex list01 0 "value01" # get specified range of elements 127.0.0.1:6379> lrange list01 0 1 1) "value01" 2) "value02" # change specified element to specified value 127.0.0.1:6379> lset list01 1 value03 OK 127.0.0.1:6379> lindex list01 1 "value03" # get the head element and remove it 127.0.0.1:6379> lpop list01 "value01" # get the last element and remove it 127.0.0.1:6379> rpop list01 "value03" # trim specified range of a List 127.0.0.1:6379> ltrim list01 1 3 OK 127.0.0.1:6379> lrange list02 0 7 1) "value01" 2) "test" 3) "value02" 4) "value03" 5) "value04" 6) "test" 7) "value05" 8) "test" # remove specified number of elements of a List 127.0.0.1:6379> lrem list02 2 test (integer) 2 127.0.0.1:6379> lrange list02 0 7 1) "value01" 2) "value02" 3) "value03" 4) "value04" 5) "value05" 6) "test" |
Sponsored Link |
|