Category Archives: Python

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!