Using Redis on Windows

DZone 's Guide to

Using Redis on Windows

Microsoft sponsored a project to port Redis onto Windows, but the project was recently discontinued according to Microsoft. What are your options now?

· Database Zone ·
Free Resource

Redis natively runs on Linux flavors (and lately on ARM). Many developers, however, want the same Redis awesomeness on Windows, as well. Microsoft sponsored a project to port Redis onto Windows, but the project was recently discontinued according to Microsoft. With this option gone, what are your options now for running Redis on Windows?

Well, you've got a few.

Run Redis on the Windows Ubuntu Subsystem

Windows 10 comes with an Ubuntu subsystem that can run Redis on your Windows host. Once you have enabled developer mode, you can run Bash on Windows 10. Launch bash and do sudo apt-get install redis-server followed by redis-server on the command prompt. You will see Redis listening on port 6379. It is important to note that the Ubuntu subsystem is a developer mode capability. This subsystem is not built for running critical applications.

Run Redis on Docker for Windows

Docker on Windows can run Linux-based containers. Simply install Docker and change your container type to Linux on Windows 10. Following the PowerShell line will switch the container type & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon. Once you have Linux containers enabled, you can simply do docker run -d -p 6379:6379 redis and you are good to go. 

Image title

With Docker, you have more options. You can also get a distributed deployment of Redis using Redis Enterprise container on Windows. 

Redis Enterprise is simple to set up and it is compatible with existing Redis applications. Simply change your connection string and you are running your Redis app. 

Three simple steps will get you there!

1. Start the Redis Enterprise Pack Container

docker run -d --cap-add sys_resource --name redis1 -p 8443:8443 -p 9443:9443 -p 12000:12000 redislabs/redis:latest

2. Setup Cluster With Redis Enterprise Pack

docker exec -d --privileged redis1 "//opt/redislabs/bin/rladmin" cluster create name cluster.local username redis@redislabs.com password redis123 flash_enabled

3. Create a Database on Port 12000

Note: you will need to run the curl command from "BASH on Windows" described above under "ubuntu subsystem in windows"

curl -u "redis@redislabs.com:redis123" -k --request POST --url https://localhost:9443/v1/bdbs --header 'content-type: application/json' --data '{"name":"db5","type":"redis","memory_size":1073741824,"port":12000}'

You are now ready to connect your Redis application to port 12000 to get things working on Windows.

Detailed steps for windows are here. You can also find the repo with the script to set up a multi-node cluster with Redis Enterprise Cluster.

database, docker, nosql, redis, tutorial, windows

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}