In this guide, we will cover several topics that will help you install Redis on Windows, and also address if this is indeed the best setup. Interested in quickly trying out Redis for free? Simply create a free Redis Cloud account!
You can download a moderately out-of-date precompiled version of Redis for 32-bit and 64-bit Windows thanks to Dusan Majkic from his GitHub page.
After you download Redis on Windows, you’ll need to extract the executables from the zip file. As long as you’re using a version of Windows more recent than Windows XP, you should be able to extract Redis without any additional software.
After you’ve extracted either the 32- or 64-bit version of Redis to a location of your choice (depending on your platform and preferences; remember that 64-bit Windows can run 32- or 64-bit Redis, but 32-bit Windows can only run 32-bit Redis), you can start Redis by double-clicking on the redis-server executable. After Redis has started, you should see a window similar to figure A.1.
If you find yourself in the position of needing the most up-to-date version of Redis on Windows as possible, you’ll need to compile Redis yourself. Your best option is to use Microsoft’s official port, which requires Microsoft Visual Studio, though the free Express 2010 works just fine. If you choose to go this route, be warned that Microsoft makes no guarantees as to the fitness of their ports to Windows for anything except development and testing.
You can install Redis cache on Windows 10 using 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.
Ever since Jessica Deen explained how WSL works at my SVDevOps Meetup, I’ve recommended Redis Windows 10 users run Redis on their own dev machines. Yes, you heard right. Starting with Windows 10 (v1709 – 2017-09, Fall Creators Update), you can run at least a half-dozen flavors of Linux on the Windows Subsystem for Linux (WSL), and you can run Redis on top of them. No VM required. No Docker. No joke!
To answer the question “Which version of Windows is my PC is running?” press your Windows logo key + R, type “winver,” then select OK. Starting with version 10, you’ve got a command called “wslconfig.” It lists distros you have and controls which one starts by typing “bash.” Try it out!
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
> sudo apt-get update > sudo apt-get upgrade > sudo apt-get install redis-server > redis-cli -v
> sudo service redis-server restart
$ redis-cli 127.0.0.1:6379> set user:1 "Jane" 127.0.0.1:6379> get user:1 "Jane"
> sudo service redis-server stop
Now that Redis on Windows is up and running, it’s time to download and install Python.
If you already have Python 2.6 or 2.7 installed, you’re fine. If not, you’ll want to download the latest version of Python 2.7, because that’s the most recent version of Python that has support for the Redis library. Go to http://www.python.org/download/ and select the most recent version of the 2.7 series that’s available for Windows in either the 32- or 64-bit version (again, depending on your platform). When Python is done downloading, you can install it by double-clicking on the downloaded .msi file.
Assuming that you accepted all of the default options for installing Python 2.7, Python should be installed in C:Python27. From here, you only need to install the Python Redis library to be ready to use Redis with Python. If you’re using Python 2.6, any time the book refers to Python27, you can instead use Python26.
To help you to install the Redis client library, you’ll use the easy_install utility from the setuptools package. This is because you can easily download setuptools from the command line. To get started, open a command prompt by going into the Accessories program group in the Start menu and clicking on Command Prompt.
After you have a command prompt open, follow along with the next listing; it shows how to download and install setuptools and the Redis client library.
Listing A.6 Installing the Redis client library for Python on Windows
Start Python by itself in interactive mode.
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit... Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib import urlopen
Import the urlopen factory function from the urllib module.
>>> data = urlopen('http://peak.telecommunity.com/dist/ez_setup.py')
Fetch a module that will help you install other packages.
>>> open('ez_setup.py', 'wb').write(data.read())
Write the downloaded module to a file on disk.
Quit the Python interpreter by running the builtin exit() function.
Run the ez_setup helper module.
Finished processing dependencies for setuptools==0.6c11
The ez_setup helper downloads and installs setuptools, which will make it easy to download and install the Redis client library.
C:Usersjosiah>c:python27python -m easy_install redis Searching for redis
Finished processing dependencies for redis
Use setuptools’ easy_install module to download and install Redis.
Now that you have Python and the Redis client library installed, read on to find out if Redis on Windows is the best setup for you.
The main drawback of Redis on Windows is that Windows isn’t officially supported on Redis. Specifically, Windows doesn’t support the fork system call, which Redis uses in a variety of situations to dump its database to disk. Without the ability to fork, Redis is unable to perform some of its necessary database-saving methods without blocking clients until the dump has completed.
Recently, Microsoft has contributed engineering time helping to address background saving issues, using threads to write to disk instead of a forked child process.
As of this writing, Microsoft does have an alpha-stage branch of Redis 2.6, but it’s only available as source, and Microsoft makes no guarantees as to its worthiness in production scenarios.
At least for the short term, there’s the previously mentioned unofficial port of Redis by Dusan Majkic that offers precompiled binaries for Redis 2.4.5. However, Redis blocks when dumping the database to disk.
Get started now with a free Redis Cloud account.
By continuing to use this site, you consent to our updated privacy agreement. You can change your cookie settings at any time but parts of our site will not function correctly without them.