bbangert / beaker

WSGI middleware for sessions and caching
https://beaker.readthedocs.org/
Other
517 stars 147 forks source link

Some much-needed features about caching #232

Open zyz954489346 opened 9 months ago

zyz954489346 commented 9 months ago

Functions needed and reasons:

  1. For mongodb mode, support for change cache default collection is required, Do not disallow modification of shaker_locks and shaker_cache collections. Because in actual scenarios, different data may be cached in different collections, which may avoid too much data in a single table.
  2. Decorator api needs to support custom configuration namespace, default file path will cause project migration or function location movement to cause cache invalidation

Hope to support these features as soon as possible.

amol- commented 9 months ago

Hi, you can setup different namespaces with mongodb in different databases, that should solve having too many keys in the same collection. Just name the databases like cache1_db, cache2_db and so on... You can set the db name in the connection url.

For the custom namespace of the decorator, providing a PR should be fairly simple if you want to contribute it. You probably just need to add an argument to https://github.com/bbangert/beaker/blob/c089668e6ebb92c6d813ce731ea3b676e0024b7a/beaker/cache.py#L545C5-L545C20 and test