Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Redis instead of storage in normal variables?

Tags:

node.js

redis

What is the advantage of using Redis for session storage over simply storing all data in variables inside your app?

like image 344
Tiddo Avatar asked Dec 27 '12 12:12

Tiddo


People also ask

Why should I use Redis?

Redis enables you to write traditionally complex code with fewer, simpler lines. With Redis, you write fewer lines of code to store, access, and use data in your applications. The difference is that developers who use Redis can use a simple command structure as opposed to the query languages of traditional databases.

Can I use Redis as storage?

Redis is a database for a range of data sizes, from a few megabytes to hundreds of terabytes. With Redis Enterprise, you can use Redis as both an in-memory cache and a primary database in a single system, thus eliminating the complexity and latency of two separate systems.

Can I use Redis instead of database?

Redis is a data structure store that can be used as a database, cache, or even a message broker. The storage structure is both open-source and in-memory. It is also NoSQL-based. This means it allows data structures like strings, hashes, lists, sets, sorted sets of data, bit maps, and so on.

For which cases is Redis more useful compared to SQL databases?

Redis is faster though than most relational databases. If you're only going to be doing key:value pair queries, then you'll want to use Redis.


1 Answers

From the top of my head:

Pros of storing sessions in external storage (redis) vs in-process

  • sessions survive crash of app server
  • sessions are shared between all app servers (if you have more than one).

Cons:

  • slower than storing in-process (because of network latency)
  • requires setting up and managing the storage
like image 189
Sergio Tulentsev Avatar answered Oct 21 '22 16:10

Sergio Tulentsev