首页 > 其他 > 详细

Redis Tutorial - 基本操作

时间:2015-07-04 12:33:25      阅读:236      评论:0      收藏:0      [点我收藏+]

http://try.redis.io/

Redis即Key-Value存储,也称为NoSQL数据库,Redis数据库的关键操作为存储key-value数据,通过key检索value

1)存储、检索、删除,自增值 SET,GET, DEL,INCR

OK
(integer) 11
(integer) 12
(integer) 1
(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 - 基本操作

原文:http://www.cnblogs.com/joshuajiang/p/4615315.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!