Install Redis on Windows and Mac
In this article, we will be installing Redis data store on Windows and Mac OS. While installing Redis on Windows, we will be using Bash on Ubuntu on Windows application to set up the Redis locally. In the mac system, we will be using Homebrew as well as .tar file to install it. Once, the installation and setup is done, we will be using command lines to perform some get and put request to the Redis cache.
Installing Redis on Mac
Installing Redis using Homebrew on Mac
Homebrew is a package manager for Mac OS similar to apt-get in Linux for installing any software. If you don't have it installed on your Mac then you can follow this guide to install Homebrew. Once, installed you can execute below command on the termonal.
brew install redis
All the installation information can be found at
Start Redis Service
There are two ways to start Redis server. Either you can start Redis as a service so that it will keep running in the background with the following command:
brew services start redis
Or, if you don't want a background service you can just run below command
Once, the Redis is started in the background, you can use
brew services stop redis to stop the service. To uninstall the server, you can execute below command.
brew uninstall redis
And, to check if the Redis servicce is running, you can run
Installing Redis Manually with .tar file on Mac
Homebrew is the best way to install any packages on mac but you can also download the zip file and manually install it. Below are the commands to install it manually.
- mkdir redis && cd redis
- curl -O http://download.redis.io/redis-stable.tar.gz
- tar xzvf redis-stable.tar.gz
- cd redis-stable
- make test
- sudo make install
Redis is implemented in C language and hence the .tar file has files with extension .c. After execution of the
make command, files with extension .o will be generated.
To start the Redis, you can run the command
Installing Redis on Windows
The Redis project does not officially support Windows. Hence, Bash on Ubuntu on Windows application is installed. You can follow this official documentation for Linux Installation Guide for Windows 10.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Once, done you can run below commands to install Redis.
sudo apt-get update sudo apt-get upgrade sudo apt-get install redis-server sudo service redis-server restart
Once, the Redis server is installed and running(default port 6379), we can use below command to test if Redis is running. The output will be
sudo service redis-server stop sudo service redis-server start sudo service redis-server restart
Common Redis Usage Command
Start Redis cli with the command
redis-cli first before trying out below commands:
redis-cli -h 18.104.22.168 -p 16379 -a "password" //connect to remote redis server at 22.214.171.124 at 16379 SET name dhiraj //adds a key value pair in Redis cache. Here the key is name and the value is dhiraj GET name //Pulls value of supplied key EXISTS name //Checks if supplied key value pair exists. Outputs 1 if true DEL name //Deletes the entry of given key if present
If You Appreciate This, You Can Consider:
About The Author
A technology savvy professional with an exceptional capacity to analyze, solve problems and multi-task. Technical expertise in highly scalable distributed systems, self-healing systems, and service-oriented architecture. Technical Skills: Java/J2EE, Spring, Hibernate, Reactive Programming, Microservices, Hystrix, Rest APIs, Java 8, Kafka, Kibana, Elasticsearch, etc.