分类: IT职场
2012-08-09 09:54:19
[root@localhost src]#
/usr/local/redis/src/redis-cli redis 127.0.0.1:6379> set name MoWenJian OK redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> get
name "MoWenJian" redis 127.0.0.1:6379> setnx name MoWenJian_New (integer) 0 redis 127.0.0.1:6379> get name "MoWenJian_New" redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> set lampbrother 10
success OK redis 127.0.0.1:6379> get lampbrother "success" redis 127.0.0.1:6379> get lampbrother (nil) redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> get
jiege "lijie@li-jie.me" redis 127.0.0.1:6379> setrange jiege 6 lampbrother.net (integer) 21 redis 127.0.0.1:6379> get lampbrother "" redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> mset hobby1 smoke hobby2 beer
hobby3 girl OK redis 127.0.0.1:6379> get hobby1 "smoke" redis 127.0.0.1:6379> get hobby3 "girl" redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> get hobby1 "smoke" redis 127.0.0.1:6379> get hobby3 "girl" redis 127.0.0.1:6379> msetnx hobby1 chouyan hobby4 hejiu (integer) 0 redis 127.0.0.1:6379> get hobby4 (nil) redis 127.0.0.1:6379> get hobby3 "girl" |
redis 127.0.0.1:6379> get hobby4 (nil) redis 127.0.0.1:6379> get hobby3 "girl" |
redis 127.0.0.1:6379> getset hobby4 football (nil) redis 127.0.0.1:6379> getset hobby3 basketball "girl" redis 127.0.0.1:6379> get hobby4 "football" redis 127.0.0.1:6379> get hobby3 "basketball" |
redis 127.0.0.1:6379> getrange jiege 0
4 "lijie" redis 127.0.0.1:6379> getrange jiege -15 -1 "lampbrother.net" redis 127.0.0.1:6379> getrange jiege 0 100 "" |
redis 127.0.0.1:6379> mget hobby1 hobby2
hobby5 1) "smoke" 2) "beer" 3) (nil) redis 127.0.0.1:6379> |
redis 127.0.0.1:6379> set age 20 OK redis 127.0.0.1:6379> incr age (integer) 21 redis 127.0.0.1:6379> get age "21" redis 127.0.0.1:6379> get age1 (nil) redis 127.0.0.1:6379> incr age1 (integer) 1 redis 127.0.0.1:6379> get age1 "1" |
redis 127.0.0.1:6379> incrby age 5 (integer) 26 redis 127.0.0.1:6379> get age "26" redis 127.0.0.1:6379> incrby age -1 (integer) 25 redis 127.0.0.1:6379> get age "25" |
redis 127.0.0.1:6379> set age 20 OK redis 127.0.0.1:6379> decr age (integer) 19 redis 127.0.0.1:6379> get age "19" redis 127.0.0.1:6379> get age1 (nil) redis 127.0.0.1:6379> decr age1 (integer) -1 redis 127.0.0.1:6379> get age1 "-1" |
redis 127.0.0.1:6379> decrby age 5 (integer) 14 redis 127.0.0.1:6379> get age "14" |
redis 127.0.0.1:6379> set name lijie OK redis 127.0.0.1:6379> get name "lijie" redis 127.0.0.1:6379> append name @li-jie.me (integer) 15 redis 127.0.0.1:6379> get name "" |
redis 127.0.0.1:6379> get
name "" redis 127.0.0.1:6379> strlen name (integer) 15 redis 127.0.0.1:6379> get age "20" redis 127.0.0.1:6379> strlen age (integer) 2 |
好了,这就是我们的莫问剑(String类型)的所有技能,为师已经传授给各位,不知各位能否深刻领悟,
如有无法体悟之处,请跟帖回复,切勿自行闭门修炼,以免走火入魔!
今天咱们就练到这里,下文将给大家详细介绍Redis的第二把剑---------游龙剑(hashes
类型)的操作,敬请期待!!!
原文地址: