Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Minimal persistent memoization cache

Project Description

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.


  • Simple usage via decorator
  • Persistent caching
  • Key expiration
  • Maximum cache size, to prevent bloat


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=5000)
def expensive_function():
    return expensive_calculation()
  • path: Path to the database file. Defaults to .cache.json.
  • timeout: How long should the data be cached in seconds. Defaults to 86400 (1 day).
  • size: Maximum number of keys cached. Defaults to 10000.

For more information, see documentation.


  • Test suite
  • Optionally retry if blank data is returned


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

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(6.0 kB) Copy SHA256 Hash SHA256
Wheel py3 Feb 11, 2018
(7.4 kB) Copy SHA256 Hash SHA256
Source None Feb 11, 2018

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting