set_cache default does not work with plugins
- 主要言語
- Python
- スター
- 1.4k
- フォーク
- 181
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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'
```
コントリビューションガイド
評価
この issue はまだ評価されていません。