码迷,mamicode.com
首页 > 其他好文 > 详细

Redis Hash操作

时间:2015-10-16 13:16:18      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:

Redis Hash操作

1、HSET key field value

  Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten.

Return value

Integer reply, specifically:

  • 1 if field is a new field in the hash and value was set.
  • 0 if field already exists in the hash and the value was updated.

  技术分享

2、HEXISTS key field

  Returns if field is an existing field in the hash stored at key.

Return value

Integer reply, specifically:

  • 1 if the hash contains field.
  • 0 if the hash does not contain field, or key does not exist.

  技术分享

3、HGET key field

  Returns the value associated with field in the hash stored at key.

Return value

Bulk string reply: the value associated with field, or nil when field is not present in the hash or key does not exist.

  技术分享

4、HDEL key field [field ...]

  Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. If key does not exist, it is treated as an empty hash and this command returns 0.

Return value

Integer reply: the number of fields that were removed from the hash, not including specified but non existing fields.

技术分享

5、HKEYS key

  Returns all field names in the hash stored at key.

Return value

Array reply: list of fields in the hash, or an empty list when key does not exist.

  技术分享

6、HVALS key

  Returns all values in the hash stored at key.

Return value

Array reply: list of values in the hash, or an empty list when key does not exist.

  技术分享

7、HGETALL key

  Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.

Return value

Array reply: list of fields and their values stored in the hash, or an empty list when key does not exist.

  技术分享

8、HLEN key

  Returns the number of fields contained in the hash stored at key.

Return value

Integer reply: number of fields in the hash, or 0 when key does not exist.

  技术分享

9、HMSET key field value [field value ...]

  Sets the specified fields to their respective values in the hash stored at key. This command overwrites any existing fields in the hash. If key does not exist, a new key holding a hash is created.

技术分享

 

Redis Hash操作

标签:

原文地址:http://www.cnblogs.com/tekkaman/p/4884939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!