zoukankan      html  css  js  c++  java
  • Redis Hash操作

    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.

      

    10、HMGET key field [field ...]

      Returns the values associated with the specified fields in the hash stored at key.

    For every field that does not exist in the hash, a nil value is returned. Because a non-existing keys are treated as empty hashes, running HMGETagainst a non-existing key will return a list of nil values.

    Return value

    Array reply: list of values associated with the given fields, in the same order as they are requested.

    11、HSETNX key field value。 NX是Not Exist的缩写。

      Sets field in the hash stored at key to value, only if field does not yet exist. If key does not exist, a new key holding a hash is created. If fieldalready exists, this operation has no effect.

    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 no operation was performed.

    12、HSTRLEN key field

      Returns the string length of the value associated with field in the hash stored at key. If the key or the field do not exist, 0 is returned.

    Return value

    Integer reply: the string length of the value associated with field, or zero when field is not present in the hash or key does not exist at all.

    13、HINCRBY key field increment

      Increments the number stored at field in the hash stored at key byincrement. If key does not exist, a new key holding a hash is created. Iffield does not exist the value is set to 0 before the operation is performed.

    The range of values supported by HINCRBY is limited to 64 bit signed integers.

    Return value

    Integer reply: the value at field after the increment operation.

    14、HINCRBYFLOAT key field increment

    参考:http://redis.io/commands/hscan

      

  • 相关阅读:
    用python自定义实现db2的连接池
    python写的爬虫工具,抓取行政村的信息并写入到hbase里
    201521123119《Java程序设计》第4周学习总结
    201521123119《Java程序设计》第5周学习总结
    201521123119《Java程序设计》第6周学习总结
    201521123119《Java程序设计》第1周学习总结
    log4j:WARN No appenders could be found for logger
    android 单元测试
    android手机屏幕适配2
    android手机屏幕适配
  • 原文地址:https://www.cnblogs.com/tekkaman/p/4884939.html
Copyright © 2011-2022 走看看