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

      

  • 相关阅读:
    Blazor 服务端组件 Render, RenderFragment ,RenderTreeBuilder, CascadingValue/CascadingParameter
    Git Submodule管理项目子模块
    使用Try.NET创建可交互.NET文档
    开包即食的教程带你浅尝最新开源的C# Web引擎 Blazor
    搞懂Xamarin.Forms布局,看这篇应该就够了吧
    【译】.NET 跨平台界面框架和为什么你首先要考虑再三
    Roslyn 语法树中的各种语法节点及每个节点的含义
    数组的子集
    查找字符串中的最长无重复字符的子串
    双通道无限蓝屏
  • 原文地址:https://www.cnblogs.com/tekkaman/p/4884939.html
Copyright © 2011-2022 走看看