标签:
【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.
标签:
原文地址:http://www.cnblogs.com/tekkaman/p/4884939.html