ring

ring - Top-level interfaces for end users.

Common ring decorators are aliased in this level as shortcuts.

ring.lru(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.lru() for synchronous version.
Note:asyncio version is based on synchronous version. It is composed using ring.func.asyncio.convert_storage().
ring.dict(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.dict() for synchronous version.
Note:asyncio version is based on synchronous version. It is composed using ring.func.asyncio.convert_storage().
ring.memcache(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.memcache() for synchronous version.
See:ring.func.asyncio.aiomcache() for asyncio version.
ring.redis(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.redis_py() for synchronous version.
See:ring.func.asyncio.aioredis() for asyncio version.
ring.shelve(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.shelve() for synchronous version.
Note:asyncio version is based on synchronous version. It is composed using ring.func.asyncio.create_asyncio_factory_proxy().
Warning:The backend storage of this factory doesn’t support asyncio. To enable asyncio support at your own risk, pass force_asyncio=True as a keyword parameter. parameter.
ring.disk(...)

Proxy to select synchronous or asyncio versions of Ring factory.

See:ring.func.sync.diskcache() for synchronous version.
Note:asyncio version is based on synchronous version. It is composed using ring.func.asyncio.create_asyncio_factory_proxy().
Warning:The backend storage of this factory doesn’t support asyncio. To enable asyncio support at your own risk, pass force_asyncio=True as a keyword parameter. parameter.
ring.aiomcache(client, key_prefix=None, expire=0, coder=None, user_interface=(<class 'ring.func.asyncio.CacheUserInterface'>, <class 'ring.func.asyncio.BulkInterfaceMixin'>), storage_class=<class 'ring.func.asyncio.AiomcacheStorage'>, key_encoding='utf-8', **kwargs)

Memcached interface for asyncio.

Expected client package is aiomcache.

aiomcache expect Memcached client or dev package is installed on your machine. If you are new to Memcached, check how to install it and the python package on your platform.

Parameters:
  • client (aiomcache.Client) –

    aiomcache client object. See aiomcache.Client().

    >>> client = aiomcache.Client('127.0.0.1', 11211)
    
  • key_refactor (object) – The default key refactor may hash the cache key when it doesn’t meet Memcached key restriction.
See:

ring.func.asyncio.CacheUserInterface() for single access sub-functions.

See:

ring.func.asyncio.BulkInterfaceMixin() for bulk access sub-functions.

See:

ring.func.sync.memcache() for non-asyncio version.

ring.aioredis(redis, key_prefix=None, expire=None, coder=None, user_interface=(<class 'ring.func.asyncio.CacheUserInterface'>, <class 'ring.func.asyncio.BulkInterfaceMixin'>), storage_class=<class 'ring.func.asyncio.AioredisStorage'>, **kwargs)

Redis interface for asyncio.

Expected client package is aioredis.

aioredis expect Redis client or dev package is installed on your machine. If you are new to Memcached, check how to install it and the python package on your platform.

Note that aioredis>=1.0.0 only supported.

Parameters:client (Union[aioredis.Redis,Callable[..aioredis.Redis]]) –

aioredis interface object. See aioredis.create_redis() or aioredis.create_redis_pool(). For convenience, a coroutine returning one of these objects also is proper. It means next 2 examples working almost same:

>>> redis = await aioredis.create_redis(('127.0.0.1', 6379))
>>> @ring.aioredis(redis)
>>> async def by_object(...):
>>>     ...
>>> redis_coroutine = aioredis.create_redis(('127.0.0.1', 6379))
>>> @ring.aioredis(redis_coroutine)
>>> async def by_coroutine(...):
>>>     ...

Though they have slightly different behavior for .storage.backend:

>>> assert by_object.storage.backend is by_object
>>> assert by_coroutine.storage.backend is not redis_coroutine
>>> assert isinstance(
...     await by_coroutine.storage.backend, aioredis.Redis)
See:ring.func.asyncio.CacheUserInterface() for single access sub-functions.
See:ring.func.asyncio.BulkInterfaceMixin() for bulk access sub-functions.
See:ring.redis() for non-asyncio version.