Learn about Redis data structures: hashes and contact us for hassle-free hosting for mongodb® and Redis®
Retrieve your connection string and start using your cluster.
2. What is Redis?
Open Source, NoSQL Database
Used by: Twitter, Pinterest, GitHub
Stores Advanced Data Structures
Client Support: Java, C, Node.js etc
Introduction to Redis Data Structures: Hashes
3. What are Hashes?
Hashes that map string names to string values
They are essentially named containers of unique fields and their values
A way to represent an object as a Redis data structure
They also provide constant time basic operations like get, set, exists, etc.
Introduction to Redis Data Structures: Hashes
4. Common Use Cases for Hashes
Suited to store objects: sessions, users,
visitors etc.
Makes it one of key data structures provided
by Redis
In its memory optimized form, it is an
excellent choice for caching large amounts of
data
Introduction to Redis Data Structures: Hashes
5. Hashes Operations in Redis
HKEYS HLEN
HGET HMGET
HEXISTS HGETALL
HDEL HINCRBY
The complete list of set related Redis commands can be found here.
Introduction to Redis Data Structures: Hashes
6. Internal Implementation
Implemented as hash tables that use the
hash function MurmurHash2
Grow via incremental resizing
Hashes with few keys can be packed
cleverly into linear array like structure
Introduction to Redis Data Structures: Hashes
7. Redis Sets vs Redis Hashes
Implemented as dictionaries
Storage optimization made for
smaller hashes
Provide constant time basic
operations
Introduction to Redis Data Structures: Hashes
Ziplist is used to optimize storage
of smaller sorted sets and lists
8. Summary
One of the well known recommendations for memory savings while using Redis
is to use hashes instead of plain strings
Small hashes are encoded in a very small space, so you should try representing
your data using hashes every time it is possible
Redis provides fairly useful and advanced operations on hashes
Introduction to Redis Data Structures: Hashes
9. Sign Up for a free 30 day Trial
Thanks for reading! Full Article here
Hosting & management for MongoDB® and Redis®. NoSQL management Simplified.
Click here for more information on Redis Hosting