Redis Tutorial - 基本操作

來源:互聯網
上載者:User

標籤:

http://try.redis.io/

Redis即Key-Value儲存,也稱為NoSQL資料庫,Redis資料庫的關鍵操作為儲存key-value資料,通過key檢索value

1)儲存、檢索、刪除,自增值 SET,GET, DEL,INCR

> SET server:name "fido"OK> GET server:name"fido"> SET connections 10OK> INCR connections(integer) 11> INCR connections(integer) 12> DEL connections(integer) 1> INCR connections(integer) 1

2) key到期 EXPIRE & TTL

#Redis can be told that a key should only exist for a certain length of time. This is accomplished with the EXPIRE and TTL commands.    SET resource:lock "Redis Demo"    EXPIRE resource:lock 120
#This causes the key resource:lock to be deleted in 120 seconds. You can test how long a key will exist with the TTL command. It returns the number of seconds until it will be deleted. TTL resource:lock => 113 // after 113s TTL resource:lock => -2

#The -2 for the TTL of the key means that the key does not exist (anymore). A -1 for the TTL of the key means that it will never expire. Note that if you SET a key, its TTL will be reset. SET resource:lock "Redis Demo 1" EXPIRE resource:lock 120 TTL resource:lock => 119 SET resource:lock "Redis Demo 2" TTL resource:lock => -1

 3) 有序列表 RPUSH, LPUSH, LLEN, LRANGE, LPOP, and RPOP

 4) 無序集合 SADD, SREM, SISMEMBER, SMEMBERS and SUNION.

 5) 有序集合 ZADD ZRANGE

 6) 散列 HSET, HGETALL, HMSET, HGET, HDEL

  HINCRBY 可以對散列裡面的某一域(field)執行自增操作 

Redis Tutorial - 基本操作

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.