Skip to main content
Skip table of contents

Cache provider: Redis

Overview

This section describes how to create and configure a Redis Cache for use with RPI. For more information about Redis installations, please navigate to https://developer.redis.com/create/ .

Windows installation

You can run Redis on Windows 10 using the Windows Subsystem for Linux (a.k.a WSL2). WSL2 is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019. WSL2 lets developers run a GNU/Linux environment (that includes command-line tools, utilities, and applications) directly on Windows. Follow these instructions to run a Redis database on Microsoft Windows 10.

  1. Turn on Windows Subsystem for Linux. In Windows 10, Microsoft replaced Command Prompt with PowerShell as the default shell. Open PowerShell as Administrator and run this command to enable Windows Subsystem for Linux (WSL):
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Reboot Windows after making the change — note that you only need to do this once.

  2. Launch Microsoft Windows Store. Then search for Ubuntu, or your preferred distribution of Linux, and download the latest version.
    start ms-windows-store:

  3. Install Redis server. Installing Redis is simple and straightforward. The following example works with Ubuntu (you'll need to wait for initialization and create a login upon first use):

CODE
sudo apt-add-repository ppa:redislabs/redis
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server

The sudo command may or may not be required based on the user configuration of your system.

  1. Restart the Redis server using the command below:
    sudo service redis-server restart

  2. Verify if your Redis server is running. Use the redis-cli command to test connectivity to the Redis database.

CODE
$ redis-cli
127.0.0.1:6379> set user:1 "Jane"
127.0.0.1:6379> get user:1
"Jane"

By default, Redis has 0-15 indexes for databases. You can change the number using NUMBER in redis.conf.

  1. Stop the Redis Server using the command below:
    sudo service redis-server stop

Linux installation

  1. From the official Debian/Ubuntu APT Repository:
    You can install recent stable versions of Redis Stack from the official packages.redis.io APT repository. The repository currently supports Debian Bullseye (11), Ubuntu Xenial (16.04), Ubuntu Bionic (18.04), and Ubuntu Focal (20.04) on x86 processors. Add the repository to the apt index, update it, and install it:

CODE
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

sudo apt-get update

sudo apt-get install redis-stack-server

  1. From the official RPM Feed:

You can install recent stable versions of Redis Stack from the official packages.redis.io YUM repository. The repository currently supports RHEL7/CentOS7, and RHEL8/Centos8. Add the repository to the repository index, and install the package.

Create the file /etc/yum.repos.d/redis.repo with the following contents:

CODE
[Redis]
name=Redis
baseurl=http://packages.redis.io/rpm/rhel7
enabled=1
gpgcheck=1

Execute the following command to install it:

CODE
curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key
sudo rpm --import /tmp/redis.key
sudo yum install epel-release
sudo yum install redis-stack-server

Realtime API configuration

This section describes how to configure Realtime API to utilize the Redis caching mechanism. Please follow the steps below.

  1. Open the appsettings.json.config file from the Realtime API web application.

  2. Ensure you have uploaded these two assemblies within the Realtime API web application’s bin directory:

  • RedPoint.Resonance.RedisCache.dll

  • StackExchange.Redis.dll

  1. In the appsettings.json.config file, locate CacheSettings and add the following entries:

CODE
 "Caches": [
              {
                  "Name": "RedisCache",
                  "Assembly": "RedPoint.Resonance.RedisCache",
                  "Class": "RedPoint.Resonance.RedisCache.RedisCacheHandler",
                  "Settings": [
                      {
                          "Key": " IPAddresses",
                          "Value": "REPLACE WITH REDIS SERVER IP ADDRESSES"
                      }
                  ]
              }
            ]

If running in a clustered Redis environment, the specified IP addresses in IPAddresses setting must be in a comma separated value list.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.