Why would I use redis?
Redis is wonderful for many reasons. I primarily use it for caching web applications like Magento 2 and WordPress. Some other great ways to use it are as a database or a message broker. You should check it out here.
How do I install it?
The official suggestion is to build the package, but I’d much rather install applications from an official package repository (PPA). This simplifies the install, upgrade, and uninstall methods greatly.
First, you’ll need to add the PPA repository to your OS.
sudo add-apt-repository ppa:chris-lea/redis-server
Next, you’ll want to update your repositories.
sudo apt update
After that, run the installation script.
sudo apt install redis-server
Check that everything installed correctly by checking the version, starting the server, and checking the status of your newly installed server.
redis-server --version sudo service redis-server start sudo service redis-server status
You can run a few commands to test out your new server by jumping into the redis-cli application that was installed with your server. If not, just install
redis-cli and boot it up.
$ redis-cli 127.0.0.1:6379> ping PONG
When you get that PONG back, it’s quite satisfying. Let’s test saving and retrieving some values.
127.0.0.1:6379> set bears-eat "beets" OK 127.0.0.1:6379> get bears-eat "beets"
Final Notes on Web Aplications
You can configure Redis with Magento 2 quite easily for some really great performance benefits. There are a lot of reasons to use Redis over a few other technologies for many reasons, which are outlined quite nicely over in the Magento DevDocs.
WordPress can easily cache with Redis with the installation of a single plugin. I love that it’s a single click away from being enabled or disabled. It’s stupid simple installation abstracts all the heavy lifting Redis does and hides the awesome power in the back-end. You’ll really love the performance boost though, and so will your visitors!