beaker icon indicating copy to clipboard operation
beaker copied to clipboard

How can I configure NamespaceManager to realize distributed cache?

Open vba34520 opened this issue 4 years ago • 0 comments

Such as MongoDB

from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options

cache_opts = {
    'cache.type': 'ext:mongodb',
    'cache.url': 'mongodb://localhost:27017/cache',
    'cache.expire': 600
}

cache = CacheManager(**parse_cache_config_options(cache_opts))


@cache.cache('fib')
def fib(n):
    if n < 2:
        return n
    return fib(n - 1) + fib(n - 2)


if __name__ == '__main__':
    result = [fib(i) for i in range(35)]
    print(result)

result

image.png

If the _id can be configure, it's easy to realize distributed cache.

Looking forward to your reply, thank you for your great work!

vba34520 avatar Aug 28 '20 09:08 vba34520