Hashes
Introduction to Redis Data Structures:
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
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
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
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
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
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
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
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

Introduction to Redis Data Structures: Hashes

  • 1.
  • 2.
    What is Redis? OpenSource, 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? Hashesthat 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 Casesfor 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 inRedis 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 ashash 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 vsRedis 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 thewell 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 fora 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