Running Redis on Windows

Redis is a popular open-source, in-memory data store that can be used as a database, message broker, or cache layer. While Redis is primarily designed for Linux and Unix-like systems, it can also be run on Windows. In this tutorial, we will explore the different ways to install and run Redis on Windows.

Installing Redis using MSOpenTech’s Port

One of the most popular and up-to-date ports of Redis for Windows is provided by MSOpenTech. You can download the latest version of Redis from their GitHub repository. Here are the steps to follow:

  1. Download the latest Redis-x64 zip file from the MSOpenTech/redis releases page.
  2. Extract the zip file to a directory of your choice, such as C:\Redis.
  3. Open a command prompt or PowerShell window and navigate to the extracted directory.
  4. Run the redis-server.exe command to start the Redis server.
  5. To connect to the Redis server, run the redis-cli.exe command.

Installing Redis using Windows Subsystem for Linux (WSL)

If you are running Windows 10 or later, you can also install Redis using the Windows Subsystem for Linux (WSL). Here are the steps to follow:

  1. Enable WSL by opening PowerShell as an administrator and running the command Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux.
  2. Restart your computer after enabling WSL.
  3. Open the Microsoft Store and search for "Ubuntu" or your preferred Linux distribution.
  4. Install Ubuntu or your chosen distribution.
  5. Once installed, open Ubuntu and run the following commands to install Redis:
sudo apt-add-repository ppa:redislabs/redis
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server
  1. Restart the Redis server by running sudo service redis-server restart.
  2. Verify that Redis is running by using the redis-cli command.

Running Redis as a Windows Service

To run Redis as a Windows service, you can use the RedisWatcher tool provided by MSOpenTech. Here are the steps to follow:

  1. Download the RedisWatcher binaries from the MSOpenTech/redis repository.
  2. Extract the zip file to a directory of your choice, such as C:\RedisWatcher.
  3. Run the InstallWatcher.msi command to install the RedisWatcher service.
  4. Open the Windows Services console and start the Redis watcher service.

Verifying Redis Installation

Once you have installed Redis using one of the above methods, you can verify that it is running by using the redis-cli command. Here are some example commands to try:

$ redis-cli
127.0.0.1:6379> set user:1 "John"
OK
127.0.0.1:6379> get user:1
"John"

This should confirm that Redis is installed and running correctly on your Windows machine.

Conclusion

In this tutorial, we have explored the different ways to install and run Redis on Windows. Whether you choose to use MSOpenTech’s port, WSL, or run Redis as a Windows service, you can now take advantage of Redis’s powerful in-memory data store capabilities on your Windows machine.

Leave a Reply

Your email address will not be published. Required fields are marked *