mocks

A set of in-process pure python implementations to match the redis based objects.

The objects from this module implement the same interface as those from the other modules, but are implemented as native python objects rather than redis calls. Whenever possible the interface and semantics should be the same.

class async_redis_objects.mocks.Set(encoder, decoder)
async add(*values)
Return type

int

async has(value)
async all()
Return type

Set[Any]

async size()
Return type

int

async remove(value)
Return type

bool

async clear()
class async_redis_objects.mocks.Queue(encoder, decoder)
async push(data)
async pop(timeout=1)
Return type

Any

async pop_ready()
Return type

Any

async clear()
async length()
class async_redis_objects.mocks.PriorityQueue(encoder, decoder)
async push(data, priority=0)
async pop(timeout=1)
Return type

Any

async pop_ready()
Return type

Any

async score(data)
async rank(data)
async clear()
async length()
class async_redis_objects.mocks.Hash(encoder, decoder)
async keys()
Return type

Set[str]

async size()

Get the number of items in the hash table.

Return type

int

async set(key, value)

Returns if the key is new or not. Set is performed either way.

Return type

bool

async add(key, value)

Returns if the key is new or not. Set only performed if key is new.

Return type

bool

async get(key)
Return type

Any

async mget(keys)
Return type

Dict[str, Any]

async all()
Return type

Dict[str, Any]

async delete(key)
Return type

bool

async clear()
class async_redis_objects.mocks.LockContext(primitive, max_duration, timeout)
class async_redis_objects.mocks.Publisher(default_channel, encoder)
async send(message=None, json=None, channel=None)
async listeners()
Return type

int

class async_redis_objects.mocks.ObjectClient(*_, encoder=None, decoder=None)
queue(name, encoder=None, decoder=None)
priority_queue(name, encoder=None, decoder=None)
hash(name, encoder=None, decoder=None)
set(name, encoder=None, decoder=None)
lock(name, max_duration=60, timeout=None)

A lock within this python process

Parameters
  • name (str) – A unique identifier for the lock

  • max_duration (int) – Max time to hold the lock in seconds

  • timeout (Optional[int]) – Max time to wait to acquire the mutex

Returns

publisher(channel, encoder=None)
Return type

Publisher