Skip to main content

Profile picture for Ajeet Raina
Ajeet Raina, was Developer Growth Manager at Redis

Create a Redis database on Mac OS

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:

Step 1. Install Redis Stack using Homebrew

First, tap the Redis Stack Homebrew tap and then run brew install as shown below:

 brew tap redis-stack/redis-stack
brew install --cask redis-stack

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.

 ==> Installing Cask redis-stack-redisinsight
==> Moving App '' to '/Applications/'
🍺 redis-stack-redisinsight was successfully installed!
==> Installing Cask redis-stack
🍺 redis-stack was successfully installed!

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:

 echo $PATH

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.

Start Redis Stack Server

You can now start Redis Stack Server as follows:


Existing Redis installation

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 ~/.bashrc or ~/zshrc (depending on your shell), and add the following line.

  export PATH=/usr/local/Caskroom/redis-stack-server/<VERSION>/bin:$PATH

Go to Applications and click "RedisInsight Preview" to bring up the Redis Desktop GUI tool.

Step 2. Add Redis database

access redisinsight

Step 3. Enter Redis database details

Add the local Redis database endpoint and port.

access redisinsight

Step 5. Redis for time series

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.

redis for timeseries

Step 6. Create time series per shop

 TS.CREATE bike_sales_1 DUPLICATE_POLICY SUM LABELS region east compacted no
TS.CREATE bike_sales_2 DUPLICATE_POLICY SUM LABELS region east compacted no
TS.CREATE bike_sales_3 DUPLICATE_POLICY SUM LABELS region west compacted no
TS.CREATE bike_sales_4 DUPLICATE_POLICY SUM LABELS region west compacted no
TS.CREATE bike_sales_5 DUPLICATE_POLICY SUM LABELS region west compacted no

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:

create time series per shop

Step 7. Running the query

execute the query

Step 8. Time series compaction

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.


 TS.CREATERULE bike_sales_5 bike_sales_5_per_day AGGREGATION sum 86400000

time series compaction