Skip to main content

# Cachalot [![PyPI version](https://badge.fury.io/py/cachalot.svg)](https://badge.fury.io/py/cachalot) [![Pipeline status](https://gitlab.com/radek-sprta/cachalot/badges/master/pipeline.svg)](https://gitlab.com/radek-sprta/cachalot/commits/master) [![Coverage report](https://gitlab.com/radek-sprta/cachalot/badges/master/coverage.svg)](https://gitlab.com/radek-sprta/cachalot/commits/master)

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.

## Features
- Simple usage via decorator
- Persistent caching
- Key expiration
- Maximum cache size, to prevent bloat

## Installation
Cachalot requires Python 3.5 or newer to run.

**Python package**

You can easily install Cachalot using pip:

`pip3 install cachalot`

**Manual**

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

```
git clone git@gitlab.com:radek-sprta/cachalot.git
cd cachalot
python3 setup.py install
```

## Usage
```python
from cachalot import Cache

@Cache()
def expensive_function():
return expensive_calculation()
```

### Advanced usage
```python
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][documentation].

## TODO
- Test suite
- Optionally retry if blank data is returned

## Contributing
For information on how to contribute to the project, please check the [Contributor's Guide][contributing]

## Contact
[mail@radeksprta.eu](mailto:mail@radeksprta.eu)

[incoming+radek-sprta/cachalot@gitlab.com](incoming+radek-sprta/cachalot@gitlab.com)

## License
MIT License

## Credits
This package was created with [Cookiecutter][cookiecutter] and the [python-cookiecutter][python-cookiecutter] project template. Inspired by [Cashier][cachier]

[cachier]: https://github.com/atmb4u/cashier
[contributing]: https://gitlab.com/radek-sprta/cachalot/blob/master/CONTRIBUTING.md
[cookiecutter]: https://github.com/audreyr/cookiecutter
[documentation]: https://radek-sprta.gitlab.io/cachalot
[python-cookiecutter]: https://gitlab.com/radek-sprta/python-cookiecutter


Metadata

Release files for Cachalot 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Cachalot 0.1.2
File Size Uploaded Provenance
cachalot-0.1.2.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for Cachalot 0.1.2
File Interpreter ABI Platform
cachalot-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / cachalot-0.1.2.tar.gz

Download URL cachalot-0.1.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c38abbf308ae586c099c31524250fd02ad085e24fc18598b1082ccc8cc5dd258
BLAKE2b-256 checksum
How to use checksums
507aa96242ebc6659a26a504d7f6890446f52246bba788009118ab4c567b651f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / cachalot-0.1.2-py3-none-any.whl

Download URL cachalot-0.1.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf8f4ec70760b9fff190129dbd5ccec0f67cc78d0031f50ad312a7cd6f2eff37
BLAKE2b-256 checksum
How to use checksums
2004222c4f3ac74a2f62c343ec1ef99f984c766a52e0d2aaac72fef192d819dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Cachalot 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page