aglyph.cache — Simple object caching support for Aglyph

Release:2.1.1

The classes in this module define mapping types that use lock objects for synchronization.

Atomic “check-then-act” operations can be performed by acquiring the cache lock, performing the check-then-act sequence, and finally releasing the cache lock.

class aglyph.cache.MutexCache[source]

Bases: aglyph.cache._LockingCache

A mapping that uses a primitive lock to synchronize access.

If the lock is held, any attempt to acquire it will block until the holding thread releases the lock.

To use a mutex cache:

cache = MutexCache()
...
with cache:
    # check-then-act
class aglyph.cache.ReentrantMutexCache[source]

Bases: aglyph.cache._LockingCache

A mapping that uses a reentrant lock to synchronize access.

If the lock is held, any attempt to acquire it by a thread OTHER than the holding thread will block until the holding thread releases the lock. (A reentrant mutex permits the same thread to acquire the same lock more than once, allowing nested access to a shared resource by a single thread.)

To use a re-entrant mutex cache:

cache = ReentrantMutexCache()
...
with cache:
    # check-then-act