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?
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.
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.
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.
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.
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):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With