Redis常用命令,redis命令

來源:互聯網
上載者:User

Redis常用命令,redis命令

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



   

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.