Install and config Redis on macOS using Homebrew
Using Homebrew
will save you lot of times in setting up and configuring the development environment on macOS.
If you don’t have it in your Mac, try installing using the guideline here.
Optional:
If you don’t update your packages for a long time. Update them using:
brew update
brew upgrade
Those 2 commands may take time. Please take your coffee (or run them later when you have time).
Install Redis
brew install redis
==> Downloading https://homebrew.bintray.com/bottles/redis-5.0.3.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring redis-5.0.3.mojave.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
🍺 /usr/local/Cellar/redis/5.0.3: 13 files, 3.1MB
Start Redis
Run Redis as a background service
brew services start redis
And stop it
brew services stop redis
If you don’t want/need a background service you can just run:
redis-server
You can configure for Redis
by editing the configuration file in
vim /usr/local/etc/redis.conf
And start Redis with the configuration file as:
redis-server /usr/local/etc/redis.conf
Interact with Redis
When Redis is running, you can interact with it via redis-cli
.
Test if Redis is running
redis-cli ping
It will reply PONG
.
All commands to use with redis-cli
can be found here.
Command I usually use when debugging: Clear all data
redis-cli flushall
Uninstall Redis
Remember to remove the plist file also.
brew uninstall redis
rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist