Skip to main content

Minimal persistent memoization cache

Project description


[![PyPI version](https://badge.fury.io/py/cachalot.svg)](https://badge.fury.io/py/cachalot)

# Cachalot
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


Project details


Download files

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

Source Distribution

cachalot-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distributions

cachalot-0.1.0-py3.6.egg (6.2 kB view details)

Uploaded Source

cachalot-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file cachalot-0.1.0.tar.gz.

File metadata

  • Download URL: cachalot-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cachalot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48e6bd89839a120bfa2b08ad3fa1239ff9fa4c5c6e5d0197b88d1af6ee1bf308
MD5 a86d6b7f8479f35589c9f933829e16da
BLAKE2b-256 3fefaa6b8b6ccc18a7274751c311c03b7d6cec72e978f2821a0b66a7dbb0585f

See more details on using hashes here.

Provenance

File details

Details for the file cachalot-0.1.0-py3.6.egg.

File metadata

  • Download URL: cachalot-0.1.0-py3.6.egg
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cachalot-0.1.0-py3.6.egg
Algorithm Hash digest
SHA256 e3758622658fa13c2ba610eff86a0df572bc3b5f9cc672abc9e037b9d7b45984
MD5 52901d0a6e6a27aa724706881491e344
BLAKE2b-256 b7d4c1dcb0f6d2977af4d283a4ac1d4653d2a866b3e865ec4753e06b48dd4780

See more details on using hashes here.

Provenance

File details

Details for the file cachalot-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cachalot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95af354e5c925c111f259c86778c1e198899a904cdfb2ee07ab9c3faa9c641ea
MD5 c998513cd0b86ef95cb3af2b857a2ef1
BLAKE2b-256 5deed162bc2aa4e4580ebb694bf249820293164270cef660db5a9bdf0dbb94cc

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page