User guide

Birdisle (an anagram of “lib redis”) is a modified version of redis that runs as a library inside another process. The primary aim is to simplify unit testing by providing a way to run tests against what appears to be a redis server, but without the hassle of starting a separate process and ensuring that it is torn down correctly.

Birdisle-py is a Python wrapper that allows Birdisle to be used from Python. It contains integrations with redis-py and aioredis to simplify usage. It also has a lower-level API that can be used for integration with other client libraries.

Birdisle is only supported on Linux, and does not currently work with Alpine (or any distribution that uses musl rather than glibc).

Server class

The documentation refers a number of times to a “server”. A server is an instance of birdisle.Server, and is the equivalent of a separate Redis server: each instance is backed by separate databases. Note that each server also uses a non-trivial number of resources (including threads and network sockets), so while it is reasonable to have a few, you will likely run into problems if you try to create thousands. The resources can be explicitly freed by calling close().

The class optionally takes the contents of a configuration file. It can be specified as either bytes or str (unicode in Python 2). In the latter case it will be encoded for consumption by Birdisle. Note that not all redis features work in birdisle (see a list of limitations), and trying to use an unsupported feature can lead to undefined behaviour including crashes.

redis-py integration

The redis-py integration is in the module birdisle.redis. Classes Redis or StrictRedis are intended to replace the redis-py classes of the same names, and are in fact subclasses.

Instead of host and port arguments, they take a server keyword argument to specify the Server. If not specified, a new server is created. Note that this is different behaviour to fakeredis, where the default is for all instances to be backed by the same data.

aioredis integration

Within the module birdisle.aioredis, the functions create_connection(), create_redis(), create_pool() and create_redis_pool() are replacements for the aioredis functions of the same names. Instead of an address, they take a Server as the first argument. If the argument is omitted, a new Server is created.