AsyncCacheAdapter¶
-
class
privex.helpers.cache.asyncx.base.
AsyncCacheAdapter
(*args, **kwargs)[source]¶ AsyncCacheAdapter is an abstract base class based on
CacheAdapter
, but with all methods designated as coroutines.Cache adapters which make use of AsyncIO, including via asyncio compatible libraries (e.g.
aioredis
), should use this class as their parent instead ofCacheAdapter
.To retain the functionality of
__getitem__()
and__setitem__()
, it obtains an event loop usingasyncio.get_event_loop()
, and then wrapsget()
orset()
respectively usingloop.run_until_complete
to be able to run them within the synchronous get/setitem magic methods.It overrides
get_or_set()
to convert it into an async method, and overridesget_or_set_async()
so thatget()
andset()
are correctly awaited within the method.-
__init__
(*args, **kwargs) Initialize self. See help(type(self)) for accurate signature.
-
Methods¶
Methods
|
Return the value of cache key |
|
Attempt to return the value of |
|
Async coroutine compatible version of |
|
Remove one or more keys from the cache. |
|
Set the cache key |
|
Update the timeout for a given |