Have you ever needed to calculate the view count for a certain file? Or number of requests for a single page? Or update a User balance either add or deduct?

You may have to store them in a Database or keep them in memory and risk losing them when the system is rebooted. Now comes in-memory caching solutions that saves efforts and guarantee data persistence, and one of the most known solution is Redis.

So, what is Redis?

Redis (REmote DIctionary Server) is an open-source software used for caching data in memory, and no need to fear losing data since Redis guarantees data persistency.

Why Redis?

  1. Speed and durability.
  2. Ease to install and use.
  3. Key-Value based caching system.
  4. Support for multiple data models or types like Lists, Sets, HyperLogLogs, Hash tables, etc..
  5. Ability to withstand multiple concurrent write requests or transactions per second, via a technique known as sharding.
  6. No strict rules pertaining to defining strict schemas or tables for data (schemaless).
  7. Support multiple languages like C, C++, C#, Perl, Python, R, Ruby, Java, Erlang and many others.


Who uses Redis?

Redis is used by many of large and leading companies in IT like Github, Pinterest, Snapchat, StackOverFlow, Craigslist, etc.

 

Small application on Redis

The example is written in C# language and StackExchange.Redis package. After installing Redis it listens on port 6379 which is the default.

First we will demonstrate some basic and useful command like KEYS to list available keys as picture No.1

Redis-1

 


To add a new key, use SET command as in picture No.2

Redis-2


 
To retrieve a value, we use GET command as in picture No.3

Redis-3

 

Now we use C# to do the same command as before

Redis-4

 

In summary, Redis offers highly performant and efficient read and write.

We touched on basic Redis commands in this article and how to use them in our application. Instructions to do so using C# has been mentioned earlier.

 

Want to get the source code? here
 

Comments

Carloscor

I can recommend.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.