Say I want to store user preferences...something simple like this:
{
"favoriteColor": "green",
"bestFriends": [
"Tom",
"Jenny",
"Horton"
]
}
What's the best, most performant way to store this in redis cache (optimized for reads)?
Imagine UserId = 123
NOTE: Below I'm using the Redis documentation's way of representing the various structures. See here.
Simple, flat, key/value pairs right in the root?
user-123-favoriteColor = green (this is a STRING type)
user-123-bestFriends = 1) "bestFriends" (SET TYPE) 2) "Tom" 3) "Jenny" 4) "Horton"Hierarchical structure (hash of values)
user-123 = 1) "favoriteColor" (STRING type) 2) "green" 3) "bestFriends" (SET TYPE) 4) "Tom" 5) "Jenny" 6) "Horton"
And a related question...is there any reason not to store user preferences in redis vs the domain sql database?
And one more related question...is it a bad idea to store all users under one root key called "users"?