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 10, 2023, 11 tweets

Excited to teach Redis core concepts in the next few days! ๐Ÿงต #Redis #thread ๐Ÿ‘‡

Redis: Open-source, highly-replicated, performant, non-relational, database & caching server. Maps keys to values with the predefined data model. Data stored in-memory data store, It is good for caching, message brokers & streaming engines

Let's start with the string data structure
String: Store and retrieve a string, serialized json, numerical values, and binary data

Syntax:
SET <KEY> <VALUE>
GET <KEY>

MSET & MGET to assign and retreive multiple key valye in single command

Below e.g you can try in redis-cli

To increment a value by 1 or n can be done using `INCR KEY` and `INCRBY KEY NUM`

Similarly to decrement a value by 1 or n can be done using `DECR KEY` and `DECRBY KEY NUM`

You can `APPEND` the value to the existing data. Notice the integer is converted to a string. Use it carefully

Did you know you can store JSON data in Redis as strings? It's easy!
To know the length of a string use `STRLEN <KEY>`

Now we know how to store and retrieve data, what if you want to delete data. It's simple

Bonus:
`EX` will cause the data to expire in n seconds. This is great When you want to store data that are time sensitive
`TTL`: To check how much time is left before the data is destroyed

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

Note: Single redis string can store a maximum of 512 MB of data

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