In-memory stores

The simplest conceivable key-value store is found in minimalkv.memory.DictStore. It lends itself well for testing or playing around with minimalkv.

class minimalkv.memory.DictStore(d: dict[str, bytes] | None = None)

Store data in a dictionary.

This store uses a dictionary as the backend for storing, its implementation is straightforward. The dictionary containing all data is available as d.

iter_keys(prefix: str = '') Iterator[str]

Iterate over all keys in the store starting with prefix.

Parameters

prefixstr, optional, default = ‘’

Only iterate over keys starting with prefix. Iterate over all keys if empty.

redis-backend

The redis-backend requires redis to be installed and uses a redis-database as a backend.

Currently, minimalkv targets the latest stable redis version, but since it uses very few commands available, it should work on older stables as well. Note that some features are unsupported on older redis-versions (such as sub-second accuracy for TTL values on redis < 2.6) and will cause redis to complain.

class minimalkv.memory.redisstore.RedisStore(redis: StrictRedis)

Uses a redis-database as the backend.

Parameters

redisredis.StrictRedis

Backend.