I just saw this blog post and thought it was interesting to look at things from this perspective rather than the opposite and more common best practices one: https://redislabs.com/blog/7-redis-worst-practices/. Who is guilty of one (or more) of these?
I my common observation most of developers follow worst practice with Hashes, instead of fetching specific fields they are interested they simply use HGETALL
take below example if you just need first_name why to call HGETALL ?
127.0.0.1:6379> HSET foo first_name "Joe"
(integer) 1
127.0.0.1:6379> HSET foo last_name "Engel"
(integer) 1
127.0.0.1:6379> HSET foo address "1 Fanatical Pl"
(integer) 1
127.0.0.1:6379> HGETALL foo
1) "first_name"
2) "Joe"
3) "last_name"
4) "Engel"
5) "address"
6) "1 Fanatical Pl"
127.0.0.1:6379> HGET foo first_name
"Joe"
1 Like
That’s a good point. I think sometimes developers just get wrapped up in old habits or things they did out of ease early on and never stop to think about the performance impacts and if there is a better approach. Habits are hard to break!
Great way of solving as i also had the same problem or called the worst practice of hashes.