1. Hashing Hash
Summary: Redis Hash is a string-type field and value mapping table. It is 0 (1) (average) to add and delete operations.
Hash is particularly useful for storing objects. is equivalent to saving each field of an object into a single string type.
storing an object in a hash type consumes less memory and makes it easier to access the entire object, saving memory because a new hash object is initially stored with Zipmap.
Method:
1. Hset sets the hash field to the specified value, and if key does not exist, it is created first. such as Hset users:001 name test001
2. Hsetnx sets the hash field to the specified value, and if key does not exist, it is created first. If field already exists, returning 0,nx is the meaning of not exist.
3. Hmset also set multiple fields for hash. Hmset user:001 name test001 age 20
4. Hget Gets the specified hash field, no time returns nil Hget user:001 name
5. Hmget get all specified hash field (if that filed not, return nil) hmget user:001 name Age
6. Hincrby The specified hash filed plus the given value Hincrby user:001 age-8 (positive increment minus)
7. Hexists test Specifies whether field exists to return 1, does not exist return 0 hexists user:001 name
8. Hlen returns the field number of the specified hash Hlen user:001 returns 2 has 2 columns
9. Hdel Delete a field Hdel user:001 name in the hash
Hkeys return hash of all field Hkeys user:001
Hvals returns all the value in the hash
Hgetall returns all field and value in the hash
Http://bbs.lampbrother.net/read-htm-tid-131711-ds-1.html
Redis data Type--hash (hashes)