標籤:
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