Getting to know Redis
Redis is like a super-fast and smart memory database that helps solve problems quickly. It’s great for handling a lot of information and can do things like make sure data is copied for safety and spread out tasks to different parts. Redis has different ways of organizing information, making it useful for many kinds of problems. It’s like having a really efficient toolbox for computer systems, and it can handle huge amounts of data and lots of requests at the same time. So, it’s not just for small projects, it can handle really big ones too!
My Redis Adventure at Graytech
My first experience with Redis was at a company that needed to search a database of user tokens and save OTP codes with allocation and expiration times. The search is needed to find out if the user is a valid user or an invalid user. The system was written to use a SQL database that performed a series of queries that would take 10–15 seconds to find matches among a lot of clients.
We relied on a slow database that couldn’t keep up with the growing number of users. Then, someone mentioned Redis. It sounded magical, almost too good to be true. But I decided to give it a try, and let me tell you, it was life-changing!
With my supervisor’s support, I spent a week learning Redis. It was like unlocking a secret world of speed and efficiency. Once I understood its magic, I built a new search function for our system. And guess what? It worked like a charm!
The difference was unbelievable. Logins were lightning fast, verified in just milliseconds! No more waiting, no more frustration. It was like a dream come true for everyone at Graytech.
Redis wasn’t just a technical fix. It was a game-changer. It taught me that even the most frustrating problems can be solved with the right tools and a curious mind. And it opened my eyes to the amazing world of technology, where new solutions are waiting to be discovered.
So, the next time you face a challenge that seems impossible, remember this story. Remember Redis. And remember, with a little effort and a lot of curiosity, you too can turn frustration into triumph!
How did I set up Redis for use?
First, I had to install Redis on my laptop. I used Terminal for it.
brew install redis
After that is finished, I launch Redis.
I started Redis using the default configuration in the terminal by running:
01. Start Redis
redis-server
Alternatively, you can specify the configuration file:
redis-server /usr/local/etc/redis.conf
To manage Redis as a background service that starts automatically on system boot, I follow these steps:
02. Start Redis
brew services start redis
03. Stop Redis
brew services stop redis
04. Restart Redis
brew services restart redis
If you are unsure whether you have installed Redis, Use the Redis Command Line Interface (CLI) by running:
redis-cli
This command will connect you to the local Redis server. You can now issue commands to interact with Redis, such as:
set mykey "Hello, Redis!"
get mykey
05. Configure Redis Authentication
config set requirepass 1234
In the above code, the password is "1234". After giving that command, you have to authenticate yourself before using Redis. For that, you can use the below command.
06. Authenticate with Redis CLI
When connecting to Redis with the CLI, you will now need to provide the password:
redis-cli
auth 1234
After giving auth <your redis password>, it will show ‘OK’ in the terminal.
Redis has been installed and configured on your macOS computer successfully. Redis may be used to alleviate the burden on your core database, create publish-subscribe messaging patterns, or cache frequently used data to improve the speed of your applications. To fully utilize Redis’s potential, experiment with different data formats and commands as you interact with it more. You may browse its comprehensive documentation.
By incorporating Redis into your application stack, you can significantly enhance performance, scalability, and overall user experience. Be sure to stay up-to-date with Redis updates and best practices to ensure your applications continue to run smoothly and efficiently.
Follow me on GitHub: MadhushaPrasad