Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benefits of Redis over c# Dictionary

I am wondering what the benefits of Redis with its C# client over Dictionary/ConcurrentDictionary and otherwise.

I am not sure when using redis is considered overkill for a dictionary storage.

Thanks.

like image 707
Aviran Cohen Avatar asked Apr 06 '14 19:04

Aviran Cohen


Video Answer


1 Answers

Redis is probably an overkill for a local, one-machine app. Especially when the data is not large.

It's mainly used as an L2 cache layer. Say you've got multiple machines serving your app, each machine can hold its own local cache and Redis can serve as a global cache for all of them.

Let's say a user of your app browses to a page or feature that requires some data from your back end database. Your app will then check its local L1 cache (Dictionary for example). That would be the fastest method as it does not involve any network roundtrip. If the data is not there, it will look for it in Redis as the global app cache. If it's there - great - fetch the data and put in in your local L1 cache. If not, go to the database, fetch the data, put it in Redis (L2) and in your local cache (L1).

You can read more on that here.

That said, there are more usages for Redis other than mere cache - Pub/Sub functionality, SETs, SORTED SETs and functionalities on them (like intersections, unions etc.) and even smart functionalities on STRING types, such as bitwise operations.

like image 90
Ofer Zelig Avatar answered Oct 07 '22 01:10

Ofer Zelig