[Email protected]:~$ cd redis-2.8.12
[Email protected]:~/redis-2.8.12$ cd src
[Email protected]:~/redis-2.8.12/src$ redis-cli
Set
Redis 127.0.0.1:6379> Get Name
"Lijie"
Redis 127.0.0.1:6379> Set name Michael
Ok
Get
Redis 127.0.0.1:6379> Get Name
"Michael"
Redis 127.0.0.1:6379> setnx name Micahel
(integer) 0
Setnx
Redis 127.0.0.1:6379> setnx Age 10
(integer) 1
Redis 127.0.0.1:6379> Setex Date 10 2010
Ok
Redis 127.0.0.1:6379> Get Date
"2010"
Redis 127.0.0.1:6379> Get Date
(nil)
Redis 127.0.0.1:6379> Set email [email protected]
Ok
Redis 127.0.0.1:6379> Get Email
"[Email protected]"
SetRange
Redis 127.0.0.1:6379> SetRange Email 8 qq.com
(integer) 18
Redis 127.0.0.1:6379> Get Email
"[Email protected]"
Mset
Redis 127.0.0.1:6379> Mset key1 M1 key2 m2
Ok
Redis 127.0.0.1:6379> Get Key1
"M1"
Redis 127.0.0.1:6379> Get Key2
"M2"
Redis 127.0.0.1:6379> Get Key2
"M2"
Redis 127.0.0.1:6379> Get Key3
(nil)
Msetnx
Redis 127.0.0.1:6379> msetnx key4 unisys.com key5 jasson.net key3 m3 key2 m2
(integer) 0
Redis 127.0.0.1:6379> Get Key4
(nil)
Redis 127.0.0.1:6379> msetnx key4 unisys.com key5 jasson.net key3 m3
(integer) 1
Redis 127.0.0.1:6379> Get Key1
"M1"
GetRange
Redis 127.0.0.1:6379> getrange key1 0 1
"M1"
Redis 127.0.0.1:6379> getrange key1 0 0
"M"
Getset
Redis 127.0.0.1:6379> Getset Key1 20
"M1"
Mget
Redis 127.0.0.1:6379> mget key1 key2 Key3 key4 key5
1) "20"
2) "M2"
3) "M3"
4) "Unisys.com"
5) "Jasson.net"
incr
Redis 127.0.0.1:6379> incr Key6
(integer) 101
Redis 127.0.0.1:6379> incr Key6
(integer) 102
Redis 127.0.0.1:6379> Get Key6
"102"
Incrby
Redis 127.0.0.1:6379> Incrby Key6 1
(integer) 103
Redis 127.0.0.1:6379> Incrby Key6 2
(integer) 105
Redis 127.0.0.1:6379> Incrby key6-2
(integer) 103
Decr/decrby
Redis 127.0.0.1:6379> DECR Key6 1
(Error) ERR wrong number of arguments for ' decr ' command
Redis 127.0.0.1:6379> DECR Key6
(integer) 102
Redis 127.0.0.1:6379> Decrby Key6 1
(integer) 101
Append
Redis 127.0.0.1:6379> Get Name
"Michael"
Redis 127.0.0.1:6379> append name. Net
(integer) 11
Redis 127.0.0.1:6379> Get Name
"Michael.net"
Strlen
Redis 127.0.0.1:6379> strlen Name
(integer) 11
This article is from the "Software Design and Development" blog, please be sure to keep this source http://yuanzhitang.blog.51cto.com/2769219/1783090
[Chapter 3] Strings (Redis)