Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Redis to store user information

Tags:

database

redis

I'm building a simple game type application where I have user authentication. I'm planning on using Redis for my database, and I was wondering what the best practice was to store users? What I understand is that I'll need a list or sorted set to store the users, and each user would be a hashmap. Is this the preferred method of storing users or is there a more optimal way?

like image 695
David Cao Avatar asked Jul 31 '15 03:07

David Cao


People also ask

Can Redis be used as a data store?

Redis can be used with streaming solutions such as Apache Kafka and Amazon Kinesis as an in-memory data store to ingest, process, and analyze real-time data with sub-millisecond latency. Redis is an ideal choice for real-time analytics use cases such as social media analytics, ad targeting, personalization, and IoT.

Can Redis be used as a relational database?

Redis is a type of database that's commonly referred to as No SQL or non-relational . In Redis, there are no tables, and there's no database-defined or -enforced way of relating data in Redis with other data in Redis.

What data should be stored in Redis?

You can store up to 512 megabytes in a Redis string. It can store any type of data, like text, integers, floats, videos, images, or audio files. In this example, SET and GET are Redis commands, which we will discuss later. name is the key, and educative is the string value that we are storing.

When should you not use Redis?

Large amount of data: Redis does not fit as a Database if we need to store very large data sets, or expect our data to grow very fast.


1 Answers

A hash per user works best in most cases. Redis documentation on data types mentions:

Redis Hashes are maps between string fields and string values, so they are the perfect data type to represent objects (e.g. A User with a number of fields like name, surname, age, and so forth):

like image 124
Albert E Avatar answered Oct 28 '22 04:10

Albert E