Redset: Redis-backed sorted sets for Python

Introduction

Redset offers simple objects that mimic Python’s builtin set, but are backed by Redis and safe to use concurrently across process boundaries. Time-sorted sets come included and are particularly interesting for use when time-sensitive and duplicate tasks are being generated from multiple sources.

Traditional queuing solutions in Python don’t easily allow users to ensure that messages are unique; this is especially important when you’re generating a lot of time-consumptive tasks that may have overlap. Redset can help with this, among other things.

Redset doesn’t mandate the use of any particular consumer process or client. Production and consumption can happen easily from any piece of Python, making usage flexible and lightweight.

Quick example

>>> import json

>>> ss = TimeSortedSet(redis.Redis(), 'json_biz', serializer=json)

>>> ss.add({'foo': 'bar1'}, score=123)
123

>>> {'foo': 'bar1'} in ss
True

>>> ss.score({'foo': 'bar1'})
123

>>> ss.pop()
{'foo': 'bar1'}

Redset is designed to be simple and pleasant to use. It was written at Percolate where it’s used for all sorts of things, especially storing sets of time-sensitive tasks.

Authors

Written by jamesob and thekantian.

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.