Redis is a very fast non-relational (NoSQL) in-memory key-value database that can store mappings between keys and five different types of values.
The key type can only be string, and the value supports five data types: string, list, set, hash table, and ordered set .
Redis supports many features, such as persisting data in memory to hard disk, using replication to expand read performance, and using sharding to expand write performance. (Recommended learning: Redis video tutorial)
Hash
Redis hash is a key value (key=>value) pair collection.
Redis hash is a mapping table of string type fields and values. Hash is particularly suitable for storing objects.
Each hash in Redis can store 232 - 1 key-value pairs (more than 4 billion).
Example
127.0.0.1:6379> HMSET runoobkey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000 OK 127.0.0.1:6379> HGETALL runoobkey 1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000"
In the above example, we set some description information (name, description, likes, visitors) of redis to the runoobkey of the hash table.
The above is the detailed content of What type is the key of redis?. For more information, please follow other related articles on the PHP Chinese website!