- Using Redis on Mac OS
- Using Redis Stack
To install Redis Stack on mac OS, use Homebrew. Make sure that you have Homebrew installed before starting on the installation instructions below.
Follow the instructions below to setup Redis Stack on your Mac OS:
First, tap the Redis Stack Homebrew tap and then run
brew install as shown below:
This will install all Redis and Redis Stack binaries. How you run these binaries depends on whether you already have Redis installed on your system.
If this is the first time you’ve installed Redis on your system, then all Redis Stack binaries will be installed and accessible from the
$PATH. On M1 Macs, this assumes that
/opt/homebrew/bin is in your path. On Intel-based Macs,
/usr/local/bin should be in your path.
To check this, run:
Then, confirm that the output contains
/opt/homebrew/bin (M1 Mac) or
/usr/local/bin (Intel Mac). If these directories are not in the output, see the “Existing Redis installation” instructions below.
You can now start Redis Stack Server as follows:
If you have an existing Redis installation on your system, then you’ll need to modify your
PATH environment variable to ensure that you’re using the latest Redis Stack binaries.
Open the file
~/zshrc (depending on your shell), and add the following line.
Go to Applications and click "RedisInsight Preview" to bring up the Redis Desktop GUI tool.
Add the local Redis database endpoint and port.
Redis Stack provides you with a native time series data structure. Let's see how a time series might be useful in our bike shop.
As we have multiple physical shops too, alongside our online shop, it could be helpful to have an overview of the sales volume. We will create one time series per shop tracking the total amount of all sales. In addition, we will mark the time series with the appropriate region label, east or west. This kind of representation will allow us to easily query bike sales performance per certain time periods, per shop, per region or across all shops.
Click "Guides" icon (just below the key) in the left sidebar and choose "Redis for the time series" for this demonstration.
As shown in the following query, we make the shop id (1,2,3,4,5) a part of the time series name. You might also notice the
DUPLICATE_POLICY SUM argument; this describes what should be done when two events in the same time series share the same timestamp: In this case, it would mean that two sales happened at exactly the same time, so the resulting value should be a sum of the two sales amounts.
Since the metrics are collected with a millisecond timestamp, we can compact our time series into sales per hour:
RedisTimeSeries supports downsampling with the following aggregations: avg, sum, min, max, range, count, first and last. If you want to keep all of your raw data points indefinitely, your data set grows linearly over time. However, if your use case allows you to have less fine-grained data further back in time, downsampling can be applied. This allows you to keep fewer historical data points by aggregating raw data for a given time window using a given aggregation function.
There are two ways to install Redis on Mac OS:
- Installing Redis from source
- Using Homebrew
Homebrew is the easiest and most flexible way to install Redis on Mac OS. It is a package management software for Mac OS. It automates the Redis installation process, making it quick and easy to add Redis to your system.
Follow the below steps to install Redis on Mac OS using
Run the following command to install and start brew service:
Use the following commands to install Redis using brew service:
Run the following command to start the Redis database in the background:
In order to run the latest version of Redis, you will need to compile Redis from the source. Follow this link to learn more about it.
It should return PONG. This command is often used to test if a connection is still alive.