Skip to main content

Efficiently cache calls to functions

Project description

cacholote

Efficiently cache calls to functions

Quick Start

>>> import cacholote
>>> cacholote.config.set(cache_db_urlpath="sqlite://")
<cacholote.config.set ...

>>> @cacholote.cacheable
... def now():
...     import datetime
...     return datetime.datetime.now()

>>> now() == now()
True

>>> with cacholote.config.set(use_cache=False):
...     now() == now()
False

Configuration

Configuration settings can be accessed using cacholote.config.get() and modified using cacholote.config.set(**kwargs). It is possible to use cacholote.config.set either as a context manager, or to configure global settings. See help(cacholote.config.set).

Defaults are controlled by environment variables and dotenv files. See help(cacholote.config.reset).

Workflow for developers/contributors

For best experience create a new conda environment (e.g. DEVELOP) with Python 3.10:

conda create -n DEVELOP -c conda-forge python=3.10
conda activate DEVELOP

Before pushing to GitHub, run the following commands:

  1. Update conda environment: make conda-env-update
  2. Install this package: pip install -e .
  3. Sync with the latest template (optional): make template-update
  4. Run quality assurance checks: make qa
  5. Run tests: make unit-tests
  6. Run the static type checker: make type-check
  7. Build the documentation (see Sphinx tutorial): make docs-build

License

Copyright 2019, B-Open Solutions srl.
Copyright 2022, European Union.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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

cacholote-0.3.2.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

cacholote-0.3.2-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file cacholote-0.3.2.tar.gz.

File metadata

  • Download URL: cacholote-0.3.2.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for cacholote-0.3.2.tar.gz
Algorithm Hash digest
SHA256 31901c1dd0a8184a18d26963386a6e4c83615ba14796a3f36fd28ddcb557a0f9
MD5 fb6944ce715f00001b45a2260b582a7d
BLAKE2b-256 c2ff641197bc1e255d9d9388143c788c6fe3bc73222d8e077546ec716698adc6

See more details on using hashes here.

File details

Details for the file cacholote-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cacholote-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for cacholote-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5360b1e911f7c9da5b7b3d8d9a1e7959823ddd526e5c451d6b37e2662213bbe2
MD5 bc2dd848470cae8c83ac0802955b3156
BLAKE2b-256 79b5c87d6aca14b66f9b0ef08f790cf20dab94b0cae45a04af04083af3e6b174

See more details on using hashes here.

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