All about using Redis in a technology stack:
Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Note though, that the case study was written before the introduction of Hashes (see “Hashes” at Data types – Redis, and the full set of related commands), hence the use of strings to represent objects.
MikeG posted good advice regarding the use of Hashes at Redis set vs hash - Stack Overflow:
Redis hashes are good for storing more complex data, like you suggest in your question. I use them for exactly that - to store objects with multiple attributes that need to be cached (specifically, inventory data for a particular product on an e-commerce site). Sure, I could use a concatenated string - but that adds unneeded complexity to my client code, and updating an individual field is not possible.
You may be right - the tutorials may simply be from before Hashes were introduced. They were clearly designed for storing Object representations: http://oldblog.antirez.com/post/redis-weekly-update-1.html
I suppose one concern would be the number of commands Redis must service when a new item is inserted (n number of commands, where n is the number of fields in the Hash) when compared to a simple String SET command. I haven’t found this to be a problem yet on a service which hits Redis about 1 million times per day. Using the right data structure to me is more important than a negligible performance impact.
In key value store - What is the purpose of colons within Redis keys - Stack Overflow, Tobias P. shows the difference between using Strings and Hashed to store namespaced data:
The colons have been in earlier redis versions as a concept for storing namespaced data. In early versions redis supported only strings, if you wanted to store the email and the age of ‘bob’ you had to store it all as a string, so colons were used:SET user:bob:email [email protected] SET user:bob:age 31
They had no special handling or performance characteristics in redis, the only purpose was namespacing the data to find it again. Nowadays you can use hashes to store most of the coloned keys:HSET user:bob email [email protected] HSET user:bob age 31
You don’t have to name the hash “user:bob” we could name it “bob”, but namespacing it with the user-prefix we instantly know which information this hash should/could have.
Redis at Pinterest - a podcast transcript - Pinterest has moved to using Redis as a persistent store, a task which was previously handled by MySQL.
Tumblr Engineering - Staircar: Redis-powered notifications - Tumblr moved their notifications system from MySQL + memcache to Redis + Staircar.
Image credit: Tumblr Engineering