Shiva Profile picture
https://t.co/aQ1DGvQ1Fo .Passionate Tech AI enthusiast & polyglot developer. Co-founder of https://t.co/CUIVlEBXXC, ReaderMonk & Mumbai.rb. Tweets are my own. #buildinpublic

Mar 13, 2023, 11 tweets

Redis Series Part 4 thread is here!
Today, we're diving into Redis `Hashes`, simple explanations, and real-world example
#redis #series #thread 🧵
If you haven't read the previous thread about the list, check it out

Hash is essentially a collection of field-value pairs, where each field is a unique identifier and each value is the associated data. Just like JSON object or python dictionary. Everything inside the hash is a string.

In this example, we gonna store the user preferences when they want to receive threadletters in nooli.in
HSET: command adds one or more fields-values to key
HSET <KEY> field1 value1 field2 value2

HGET: command returns the value of a field for the given key

HGET <KEY> field

HMGET: commands return one or more values of the fields for the given key

HMGET <KEY> field1 field2

HEXISTS: commands to check if the field exists for a given key, if the data is present return 1 else 0

HEXISTS <KEY> field

HKEYS: command returns all the fields of the given key

HKEYS <KEY>

HVALS: command returns all the values of the given key
HVALS <KEY>

HGETALL: command returns all the fields and values for the given key
HGETALL <KEY>

Bonus
HINCRBY: increments the value at a given field by the integer for the provided key.

Thanks for reading this thread! If you're interested in learning more about Redis, follow me @_rshiva
& don't forget to retweet the 1st thread to help other devs.
I'm passionate about #buildinginpublic,
web development, &
sharing my learnings with others.
Stay tuned for more

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling