1 创建-是否存储-查看-删除
set name maojun;exists name;get name;del name;
2 序列化记录
set name maojun;exists name;dump name;退出客户端在进入,exists name,name依然存在。
3 给key设置生存时间-修改生存时间
set name maojun;exists name;expire name 30;expire name 3000;ttl name;
4 插入几条记录-查看所有的key
mset one 1 twon 2 three 3;key *;
5 记录从db0挪到db1
select 0;set name maojun;get name;move name 1;select 1;get name;
6 移除key的失效时间
set name maojun;ttl name;expire name 3000;ttl name;persist name;ttl name
7 随机返回一个key
randomkey
7 更换key的名字
set name maojun;get name;rename name self-name;get self-name;exists name;
8 反序列化(根据磁盘上的value值给新的key赋值)
set name maojun;get name ;dump name;exit;./redis-cli -h 192.168.121.128 -p 6379;get name;dump name;restore name-another 0 "\x00\x06maojun\x06\x00 \x1dyY\xd9&\x94\xf6";exit;keys *
9 对value排序
lpush step 1 2 3 4 1;sort step;sort step desc;lpush website www.so.com www.baidu.com www.google.com;sort website alpha;sort website alpha desc;sort website alpha desc limit 0 1;
10 查看类型
set name maojun;get name;type name;
11 value 追加
set name maojun;append name " wang";
12 HashTable的创建-查询-删除
hset abbr a apple;hset abbr b banana;hset abbr c cat;hset abbr d dog;hget all abbr;hget abbr a;hdel abbr a b c d;
13 HashTable整形数值value大小调整
hincrby counter pv 200;hget counter pv;hincrby counter pv 300;hincrby counter pv -100;hget counter pv;
14 HashTable Float类型数值大小调整
hincrby mykey f1 20.1;hincrby mykey f1 0.3;hget mykey f1;
16 HashTable 创建-key查看-查看记录数量-一次取多条记录-取出所有的value
hmset website google www.google.com so www.so.com baidu www.baidu.com;hkeys website; hlen website;hmget website google so
1) "www.google.com";hvals website
原文地址:http://blog.csdn.net/hi_1234567/article/details/46401179