Redis on Windows



  1. Redis supports Unix system so in order to support Windows it requires some tweaks. You can download the MSI at
  2. In python environment:
    pip install redis

One simple example to set and get string values

import redis

r = redis.Redis()
r.set('foo', 'bar')
value = r.get('foo').decode('utf-8')

Note: r.get('foo') will return b'bar' which is a byte string – redis will auto-encode a unicode string for you on the way in. r.get('foo').decode('utf-8') decode it using utf-8.


You can even save objects

class Person:
    def __init__(self, name, age): = name
        self.age = age

    def grow(self):
        self.age += 1

    def __repr__(self):
        return str.format("Name={name}, Age={age}",, age=self.age)

p = Person("Han", 32)
r.set('han', p)

Have fun!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s