redis-data structure (hashed hash)

Source: Internet
Author: User
Tags hash redis

Each hash can store 4,294,967,295 key-value pairs


Type of hash (hash):



Hset Assignment Value

127.0.0.1:6379> hset H1 username java1234
(integer) 1
127.0.0.1:6379> hset H1 Password 123456
(integer) 1



Hget value

127.0.0.1:6379> Hget H1 username
"Java1234"
127.0.0.1:6379> hget H1 Password
"123456"



Hmset multiple fields together set

127.0.0.1:6379> hmset h2 username open1111 password 123456
Ok
127.0.0.1:6379> hget H2 username
"Open1111"
127.0.0.1:6379> hget H2 Password
"123456"



Hmget multiple fields together to get

127.0.0.1:6379> hmget H2 username password
1) "open1111"
2) "123456"



Hgetall get hash all key value pairs

127.0.0.1:6379> Hgetall H2
1) "username"
2) "open1111"
3) "Password"
4) "123456"



Hdel Delete attributes (one or more at a time)

One

127.0.0.1:6379> Hgetall H1
1) "username"
2) "java1234"
3) "Password"
4) "123456"
127.0.0.1:6379> Hdel H1 username
(integer) 1
127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"

Multiple

127.0.0.1:6379> Hgetall H2
1) "username"
2) "open1111"
3) "Password"
4) "123456"
127.0.0.1:6379> Hdel H2 username password
(integer) 2
127.0.0.1:6379> Hgetall H2
(empty list or set)



Hincrby adding numbers

127.0.0.1:6379> Hset H1 age 20
(integer) 1
127.0.0.1:6379> Hget H1 Age
"20"
127.0.0.1:6379> Hincrby H1 age 5
(integer) 25
127.0.0.1:6379> Hget H1 Age
"25"



Hexists the existence of a field 1 indicates that there is 0 indicating that there is no

127.0.0.1:6379> hexists H1 Age
(integer) 1
127.0.0.1:6379> hexists H1 Age1
(integer) 0



Hlen Perhaps the number of hash attributes

127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"
3) "Age"
4) "25"
127.0.0.1:6379> Hlen H1
(integer) 2



Hkeys Get all property names

127.0.0.1:6379> Hlen H1
(integer) 2
127.0.0.1:6379> Hkeys H1
1) "Password"
2) "Age"



Hvals Get all property values

127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"
3) "Age"
4) "25"
127.0.0.1:6379> hvals H1
1) "123456"
2) "25"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.