What is Redis?
This article is an introduction for people who have heard of Redis but are not sure what it really is and what it does. We’ll fill you in on all the important facts and details about Redis. If you Redis is a technology you’re considering using in your application or was suggested to you, we’ll discuss the situations where it excels. Without further ado let’s jump in and learn about Redis!
What is Redis?
Redis is a NoSQL based database that works with key-value pairs. It’s like MongoDB in that sense but the main difference is that MongoDB is disk-based while Redis is memory-based. Like the other NoSQL databases it does not require you to setup a schema to get started like relational databases require, we don’t need to define all our tables, rows, and columns to begin. Redis also doesn’t serve raw data like a traditional sql database might but is known as a data structure server, meaning that it serves to you data that is structured. So before you get started you do want to think about what data structures you will use to store your data ( sets, lists, strings, hashes etc. ).
Primary Use Case
The primary use case for Redis is for caching because it can retrieve data from memory faster than MongoDB can retrieve data from disk. So the primary use case in short would be speed.
Store Data You Know You Need
If there’s data that you’re not sure if you’ll need, that’s typically not something that’s stored in Redis. In Redis you typically store only data that you’ll know you need so you want that data in-memory to be retrieved as quickly as possible.
So it’s like Memcached?
It is similar to the technology Memcached which also stores data in memory. They key difference with Memcached is that while Memcached uses a volatile cache so the data gets lost on a restart but Redis uses built-in persistence so the data will not be lost on a restart.
Data Types Provided in Redis
One of the great features of Redis is that it offers an array of great datatypes. Let’s take a look at them. If you don’t understand what they are now, that’s ok, just get know that they exist:
- Sorted Sets
- Geospatial Indexes
It supports partitioning so your data is not limited to the memory of a single computer but you can spread your data across multiple computers running Redis.
Generally speaking, Redis is not a service that is typically exposed directly to users. It’s typically accessed only by your trusted application servers.
All the Redis Clients / Drivers
Redis supports custom indexing so you can speed up the retrieval of your data based on how your data is used.
In this article we went over the fundamentals of Redis. The main point we’d like you to take away is that Redis is a database technology for storing data that you know you will need. Redis is typically not used to store data that you’re unsure will ever be accessed. Redis is fast in-memory storage and you want to reserve it for data that you’re certain will be accessed and might be accessed frequently.
If you have any questions about how you might apply Redis to your application please don’t hesitate to reach out to us at Object Rocket. We can make suggestions and we can handle all the complexities of setting up in production.