Skip to main content

AutoCacher

AutoCacher is an experimental Python package that automatically adds in-memory caching to public synchronous functions in the current Python script.

Instead of manually adding a cache decorator to every function, define your functions and call enable() once.

AutoCacher v0.1.1 is an experimental alpha release. It is intended for testing, learning and feedback rather than production applications.

Installation

pip install autocacher

Basic usage

import autocacher

def expensive_calculation(number):
    print("Calculating...")
    return number ** 2

# Call enable only after defining the functions.
autocacher.enable()

print(expensive_calculation(10))  # Cache miss
print(expensive_calculation(10))  # Cache hit

How it works

AutoCacher scans public synchronous functions defined in the current __main__ module and replaces them with cached wrappers.

Function arguments are serialized and hashed to generate cache keys. Results are stored in memory for the lifetime of the Python process.

Current limitations

AutoCacher v0.1:

  • Uses an in-memory cache
  • Scans only functions available when enable() is called
  • Does not cache asynchronous functions
  • Does not cache generator functions
  • Does not persist results between program executions
  • Has no expiration or maximum cache size
  • Should not be used with functions that perform side effects
  • Should not be used for database writes, file writes, payments or messages

Important warning

Only cache functions whose output depends completely on their arguments.

Do not automatically cache functions that:

  • Modify files or databases
  • Send emails or messages
  • Generate random values
  • Read frequently changing external data
  • Depend on time, global variables or environment state

Version

Current version: 0.1.1

License

AutoCacher is released under the MIT License.

Metadata

Release files for autocacher 0.1.1

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

Source distribution (sdist)

Source distribution for autocacher 0.1.1
File Size Uploaded Provenance
autocacher-0.1.1.tar.gz 4.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 8.9 kB

Release files / autocacher-0.1.1.tar.gz

Download URL autocacher-0.1.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ad9eccf88c5acea575411f2da1ed432dfaa6654b81171b12ea256473d2601c62
BLAKE2b-256 checksum
How to use checksums
1311e02229f9166d23b8f4b690c6e01cb2ebb856a833a54e03c8900017a21008
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / autocacher-0.1.1-py3-none-any.whl

Download URL autocacher-0.1.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1167eb3b962742074dada6644f85f3694c92875d3930ae973a48af6b2e7f944
BLAKE2b-256 checksum
How to use checksums
9ab34ad1db7bc34853cd7f899fab29a5b23772f824329f2c7fd6e7687580a774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Security for autocacher 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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