Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you use redis over localStorage if you only needed less than 5MB of storage?

I'm trying to figure out if using localStorage is better than redis for storing sets of data that won't go over the 5MB limit of localStorage. In the website I'm implementing, the plan is when an end user goes to any page then a check is made on whether the user has the most recent data stored in localStorage. If not, then refresh it.

By doing it this way the user won't need to go to an outside datastore like redis which should make it faster.

I couldn't find any resources online that could answer this question. I'm not sure if the reason why is because I'm going about it the wrong way or not.

Thanks for your help!

like image 718
perseverance Avatar asked Feb 15 '13 05:02

perseverance


People also ask

Which is better localStorage or session storage?

For most cases, we use the localStorage object if we want some data to be on the browser. If we want it on the server, then we use cookies, and the sessionStorage is used when we want to destroy the data whenever that specific tab gets closed or the season is closed by the user.

When should you not use localStorage?

The following are limitations, and also ways to NOT use localStorage : Do not store sensitive user information in localStorage. It is not a substitute for a server based database as information is only stored on the browser. localStorage is limited to 5MB across all major browsers.

How much data we can store in localStorage?

It is limited to about 5MB and can contain only strings. LocalStorage is not accessible from web workers or service workers. Cookies have their uses, but should not be used for storage.


2 Answers

I would say one reason you did not find any answer to this question is probably because Redis is not supposed to be used from the browser ...

Considering localStorage is a browser facility, it cannot be compared with Redis. Redis provides remote storage for backends. It is not supposed to be exposed on the Internet, but rather deployed on a trusted network (like many other NoSQL stores).

IMO you are comparing apples and oranges here ...

like image 80
Didier Spezia Avatar answered Sep 30 '22 19:09

Didier Spezia


@Didier or anyone else ...

What if the webapp is on a trusted company network? How would you answer it then? Because the same question as OP has crossed my mind.

Redis is simply a cached service to speed up data access. So the question is, when one is considering the use of Redis on a intra company web app, then does it may make sense to use Local Storage as the cache, instead of Redis, to speed data access. That is the root of the question.

EDIT: found something interesting BankersBox - Mimics Redis api and uses local storage as the persistent data store. https://github.com/twilio/BankersBox

like image 38
nanonerd Avatar answered Sep 30 '22 19:09

nanonerd