Cachalot PyPI version Pipeline status Coverage reportDownloads

Cachalot is a minimal persistent memoization cache. It provides a decorator, that stores function result for future use. Perfect for heavy computations and I/O operation (such as web requests). On backend, it uses TinyDB for storage.



Cachalot requires Python 3.5 or newer to run.

Python package

You can easily install Cachalot using pip:

pip3 install cachalot


Alternatively, to get the latest development version, you can clone this repository and then manually install it:

git clone
cd cachalot
python3 install


from cachalot import Cache

def expensive_function():
    return expensive_calculation()

Advanced usage

from cachalot import Cache

@Cache(path='cache.json', timeout=3600, size=5e3, filesize=1e6, retry=True, renew_on_read=True)
def expensive_function():
    return expensive_calculation()

Manually deleting entries

If you want to manually invalidate an entry, you can calculate the hash of the function call and then pass it the remove method.

key = cache.calculate_hash(len)('teststring')

For more information, see documentation.


For information on how to contribute to the project, please check the Contributor's Guide




MIT License


This package was created with Cookiecutter and the python-cookiecutter project template. Inspired by Cashier

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Evan Widloski


Saša Tomić


This project follows the all-contributors specification. Contributions of any kind welcome!