Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

acachetools provides asyncio-compatible versions of cachetools.cached() and cachetools.cachedmethod(), with support for cachetools cache implementations such as TTLCache and LRUCache. Concurrent calls for the same cache key share a single in-flight computation, preventing cache stampedes.

Installation

pip install acachetools

Usage

cached

from cachetools import TTLCache
from acachetools import cached

@cached(cache=TTLCache(maxsize=1024, ttl=600))
async def some_func(value: int):
    ...

cachedmethod

from cachetools import LRUCache
from acachetools import cachedmethod


class SomeClass:
    def __init__(self):
        self.cache = LRUCache(maxsize=128)

    @cachedmethod(lambda self: self.cache)
    async def some_func(self, value: int):
        ...

About

Async cachetools decorators with stampede protection

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages