aio-libs / aio-libs/aiocache

Allow all parameters in the cache config, and override them in specific usages

オープン
#387 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
feature
主要言語
Python
スター
1.4k
フォーク
181
PR マージ指標
30日以内にマージされた PR はありません

説明

When setting the cache config, I'd like to set there default values (for TTL and namespace for example):

```py
caches.set_config({
'default': {
'cache': "aiocache.SimpleMemoryCache",
'namespace': 'my_namespace',
'ttl': 60,
},
})
```
From that point, all the usages of the `default` cache would use the namespace and ttl set, unless passed explicitly in decorators and calls:

```py
@cached(alias='default')
async def something_cached(self):
# This would cache with the default parameters defined in the config
return await do_stuff()

@cached(alias='default', namespace='another_namespace', ttl=3600)
async def something_else_cached(self):
# This would cache with the parameters defined in the decorator instead of the config
return await do_stuff()

# Same for these
caches.get('default').get('foo', default=False, namespace='bar_namespace')
caches.get('default').set('foo', True, namespace='bar_namespace', ttl=86400)
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。