Redis(2.8.3) 命令學習 - Hashs

來源:互聯網
上載者:User

標籤:

HDEL key field [field ...]

Delete one or more hash fields

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HEXISTS book.1 title(integer) 1127.0.0.1:6379> HDEL book.1 title(integer) 1127.0.0.1:6379> HEXISTS book.1 title(integer) 0

 

HEXISTS key field

Determine if a hash field exists

127.0.0.1:6379> HSET book.1 title helloworld(integer) 1127.0.0.1:6379> HEXISTS book.1 title(integer) 1127.0.0.1:6379> HEXISTS book.1 title2(integer) 0127.0.0.1:6379> HEXISTS book.2 title(integer) 0

 

HGET key field

Get the value of a hash field

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 1127.0.0.1:6379> HGET book.1 title"helloworld"127.0.0.1:6379> HGET book.1 author"Mr.404"

 

HGETALL key

Get all the fields and values in a hash

127.0.0.1:6379>  HSET book.1 title helloworld(integer) 1127.0.0.1:6379> HSET book.1 author Mr.404(integer) 1127.0.0.1:6379> HGETALL book.11) "title"2) "helloworld"3) "author"4) "Mr.404"

 

HINCRBY key field increment

Increment the integer value of a hash field by the given number

127.0.0.1:6379> HSET book.1 price 30(integer) 1127.0.0.1:6379> HINCRBY book.1 price 10(integer) 40127.0.0.1:6379> HINCRBY book.1 price -5
(integer) 35

 

HINCRBYFLOAT key field increment

Increment the float value of a hash field by the given amount

127.0.0.1:6379> HSET book.1 price 30(integer) 0127.0.0.1:6379> HINCRBYFLOAT book.1 price 9.99"39.99"127.0.0.1:6379> HINCRBYFLOAT book.1 price -4.5"35.49"

 

HKEYS key

Get all the fields in a hash

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 0127.0.0.1:6379> HKEYS book.11) "title"2) "author"

 

HLEN key

Get the number of fields in a hash

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 0127.0.0.1:6379> HLEN book.1(integer) 2


HMGET key field [field ...]

Get the values of all the given hash fields

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 0127.0.0.1:6379> HMGET book.1 author title1) "Mr.404"2) "helloworld

 

HMSET key field value [field value ...]

Set multiple hash fields to multiple values

127.0.0.1:6379> HMSET book.1 title helloworld author Mr.404OK127.0.0.1:6379> HGET book.1 title"helloworld"127.0.0.1:6379> HGET book.1 author"Mr.404"

 

HSET key field value

Set the string value of a hash field

127.0.0.1:6379> HSET book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 1127.0.0.1:6379> HGET book.1 title"helloworld"127.0.0.1:6379> HGET book.1 author"Mr.404"

 

HSETNX key field value

Set the value of a hash field, only if the field does not exist

127.0.0.1:6379> HSETNX book.1 title helloworld(integer) 1127.0.0.1:6379> HSETNX book.1 title hellopython(integer) 0127.0.0.1:6379> HGET book.1 title"helloworld"

 

HSTRLEN key field

Get the length of the value of a hash field

More: http://redis.io/commands/hstrlen

 

HVALS key
  Get all the values in a hash

127.0.0.1:6379> HSETNX book.1 title helloworld(integer) 0127.0.0.1:6379> HSET book.1 author Mr.404(integer) 1127.0.0.1:6379> HVALS book.11) "helloworld"2) "Mr.404"

 

HSCAN key cursor [MATCH pattern] [COUNT count]

Incrementally iterate hash fields and associated values

More: http://redis.io/commands/hscan, http://www.redis.cn/commands/hscan.html

 

Redis(2.8.3) 命令學習 - Hashs

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.