redis string操作

阅读更多

redis 127.0.0.1:6379[1]> keys *

1) "caches"

redis 127.0.0.1:6379[1]> get caches

"ehcache"

redis 127.0.0.1:6379[1]> set caches newCache

OK

redis 127.0.0.1:6379[1]> get caches

"newCache"

redis 127.0.0.1:6379[1]> setnx caches newCache

(integer) 0

redis 127.0.0.1:6379[1]> get caches

"newCache"

redis 127.0.0.1:6379[1]> setnx caches cache

(integer) 0

redis 127.0.0.1:6379[1]> get caches

"newCache"

redis 127.0.0.1:6379[1]> mset date "2013-07-22" time "16:00" 

OK

redis 127.0.0.1:6379[1]> mget date time 

1) "2013-07-22"

2) "16:00"

redis 127.0.0.1:6379[1]> append time ":00"

(integer) 8

redis 127.0.0.1:6379[1]> get time

"16:00:00"

redis 127.0.0.1:6379[1]> getset time "15:00:00"

"16:00:00"

redis 127.0.0.1:6379[1]> strlen time

(integer) 8

redis 127.0.0.1:6379[1]> set age 22

OK

redis 127.0.0.1:6379[1]> decr age

(integer) 21

redis 127.0.0.1:6379[1]> decr age

(integer) 20

redis 127.0.0.1:6379[1]> decrby age 2

(integer) 18

redis 127.0.0.1:6379[1]> incr age

(integer) 19

redis 127.0.0.1:6379[1]> incrby age 2

(integer) 21

redis 127.0.0.1:6379[1]> quit

你可能感兴趣的:(redis,redis-cli,set,get,type)