Open
Description
Using set_config
with a plugin does not work. You must call it with an alias in order to get it to work.
See below:
from aiocache import caches, SimpleMemoryCache, cached
import asyncio
default_cached_config = {
"cache": SimpleMemoryCache,
"plugins": [{"class": "aiocache.plugins.HitMissRatioPlugin"}],
}
caches.set_config({"default": default_cached_config, "my_cache": default_cached_config})
@cached(alias="my_cache")
async def foo():
return "bar"
@cached()
async def default():
return "default bar"
async def main():
print(await foo(), foo.cache.hit_miss_ratio)
print(await default(), default.cache.hit_miss_ratio) # Error here, because default has no plugin
asyncio.run(main())
Exception has occurred: AttributeError
'SimpleMemoryCache' object has no attribute 'hit_miss_ratio'
Metadata
Metadata
Assignees
Labels
No labels