您好,登錄后才能下訂單哦!
Hasehes
Redis hash是一個string類型的field和value映射表。hash特別適合于存儲對象。相對存成string,現在存為一個hash類型中可以占用更少的內存。且可以更方便的存儲整個對象。
hset
redis 127.0.0.1:6379> hset user:001 name michael (integer) 1 redis 127.0.0.1:6379> hget user:001 name "michael"
hsetnx
redis 127.0.0.1:6379> hsetnx user:003 name jason (integer) 1 redis 127.0.0.1:6379> hsetnx user:003 name tom (integer) 0 -- set failed redis 127.0.0.1:6379> hget user:003 name "jason" -- value is not changed.
hmset/hmget
redis 127.0.0.1:6379> hmset user:004 name michael age 29 sex 1 OK redis 127.0.0.1:6379> hget user:004 name "michael" redis 127.0.0.1:6379> hget user:004 age "29" redis 127.0.0.1:6379> hget user:004 sex "1" redis 127.0.0.1:6379> hmget user:004 name age sex 1) "michael" 2) "29" 3) "1"
hincrby
redis 127.0.0.1:6379> hincrby user:004 age 5 (integer) 34 redis 127.0.0.1:6379> hget user:004 age "34"
hexists
redis 127.0.0.1:6379> hexists user:004 age (integer) 1 redis 127.0.0.1:6379> hexists user:004 address (integer) 0
hlen
redis 127.0.0.1:6379> hlen user:004 (integer) 3
hdel
redis 127.0.0.1:6379> hdel user:004 age (integer) 1 redis 127.0.0.1:6379> hexists user:004 address (integer) 0 redis 127.0.0.1:6379> hget user:004 age (nil)
hkeys hvals hgetall
redis 127.0.0.1:6379> hkeys user:004 1) "name" 2) "sex" redis 127.0.0.1:6379> hvals user:004 1) "michael" 2) "1" redis 127.0.0.1:6379> hgetall user:004 1) "name" 2) "michael" 3) "sex" 4) "1"
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。