Closed
Description
Is it possible to supply a cache object to the decorator @cached
?
It seems like there are two separarte tracks for using aiocache
:
- Create a cache with the
Cache()
constructor. This allows inspection and manual reuse of the cache. In particular, this is the track used in the example forplugins
, such as inspecting thehit_miss_ratio
stats on aHitMissRatioPlugin
. - Decorate a coroutine with
@cached
. This track accepts a class type for a cache rather than a cache object.This nominally allows plugins, and indeed the generated cache object receives and contains the list of plugins. However, the generated cache does not appear to implement the plugin functionality. For example, after passing aHitMissRatioPlugin()
object to theplugins
parameter of@cached
, the cache injected into the coroutine does not have a member calledhit_miss_ratio
.
Is it possible to pass a cache object, rather than a cache class to the @cached
decorator? This would allow the same cache to be shared between multiple function calls. Also it seems to be necessary helpful for utilizing plugin functionality.
On the flip side: Is there a driving force for supplying a cache class (rather than a cache object) to the @cached
decorator?
**** Or am I missing something: Dose this functionality already exists and I am simply not using it correctly?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels