Skip to main content

Redis native types for Python

Project description

Redis bindings is an attempt to bring Redis types into Python as native ones. It is based on redis-py and has the following types implemented so far:

Moreover, it provides some Redis descriptor interfaces:

  • IRedisField
  • IRedisListField

It is exactly interfaces, because it requires user to override get_key_name method to define key name for Redis. Here is an example of how it can be implemented (can be found in

from redis import Redis
from redistypes.descriptors import IRedisField, IRedisListField

r_connection = Redis()

class RedisField(IRedisField):
    def __init__(self, pickling=True):
        super(RedisField, self).__init__(

    def get_key_name(self, instance):
        return ':'.join([
            instance.__class__.__name__, str(,

class RedisListField(IRedisListField, RedisField):

class Student:
    name = RedisField()
    subjects = RedisListField()

    def __init__(self, pk): = pk

The Student class defined above can do the following things:

>>> from example import Student
>>> s = Student(pk=1)
>>> = 'John Galt'
>>> s.subjects = ['math', 'physics']
John Galt
>>> s.subjects
RedisList: ['math', 'physics']
>>> s.subjects.append('p.e.')
>>> s.subjects
RedisList: ['math', 'physics', 'p.e.']
>>> # Values stored inside the Redis types are immutable!
>>> s.subjects.append({'name': 'art', 'avg_score': 4.5})
>>> s.subjects[3]
{'avg_score': 4.5, 'name': 'art'}
>>> s.subjects[3]['avg_score'] = 3
>>> s.subjects[3]
{'avg_score': 4.5, 'name': 'art'}


All values stored inside the Redis types are immutable! As the example above shows, an attempt to change the value stored in the dictionary inside the RedisList leads to nothing.


  • Querying over the pipe
  • RedisDict

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for redistypes, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size redistypes-0.2.0-py3-none-any.whl (6.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size redistypes-0.2.0.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page