A disk-based caching utility for Python functions
Project description
dcache
A disk-based caching utility for Python functions.
Installation
pip install cache_on_disk
Usage
Basic Usage
from cache_on_disk import dcache
# For synchronous functions
@dcache
def expensive_function(x, y):
# Some expensive computation
return x + y
# For asynchronous functions
@dcache
async def async_expensive_function(x, y):
# Some expensive async computation
return x + y
With Required Arguments
You can specify which keyword arguments are required for caching:
@dcache(required_kwargs=["user_id"])
def get_user_data(user_id, include_history=False):
# This will only be cached if user_id is provided as a keyword argument
return {"user_id": user_id, "history": get_history(user_id) if include_history else None}
Custom Cache Configuration
from dcache import DCache
# Create a custom cache instance
my_cache = DCache(n_semaphore=50, cache_dir="/path/to/cache")
@my_cache
def my_function():
# This will use the custom cache configuration
pass
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cache_on_disk-0.2.1.tar.gz.
File metadata
- Download URL: cache_on_disk-0.2.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ee4bf1171f9e98f3f4b18284a3f743c35f6d197ce4c9d40170fb6bf0af6cae6
|
|
| MD5 |
2c91fc00dbd03e8b873655c5600afcbe
|
|
| BLAKE2b-256 |
47043bd25c838555a09a41b27c293e5e3630cac4eb012c16641d3bb6ff663bda
|
Provenance
The following attestation bundles were made for cache_on_disk-0.2.1.tar.gz:
Publisher:
manual_publish.yaml on nielsrolf/dcache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cache_on_disk-0.2.1.tar.gz -
Subject digest:
8ee4bf1171f9e98f3f4b18284a3f743c35f6d197ce4c9d40170fb6bf0af6cae6 - Sigstore transparency entry: 207902510
- Sigstore integration time:
-
Permalink:
nielsrolf/dcache@6cff29caf6ab33979985cb928f66a6f0bba0d63f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nielsrolf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual_publish.yaml@6cff29caf6ab33979985cb928f66a6f0bba0d63f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cache_on_disk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: cache_on_disk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0790a03fc58b8f04a4e112284d64e33e34a456dddf5b69992bafab1411f9e2b
|
|
| MD5 |
22ed7ab050901b86e66f5a08867cff28
|
|
| BLAKE2b-256 |
45d1326df137f8e1d291651dfc37fe1c07df099b5f5d8330fd92f3880deda863
|
Provenance
The following attestation bundles were made for cache_on_disk-0.2.1-py3-none-any.whl:
Publisher:
manual_publish.yaml on nielsrolf/dcache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cache_on_disk-0.2.1-py3-none-any.whl -
Subject digest:
d0790a03fc58b8f04a4e112284d64e33e34a456dddf5b69992bafab1411f9e2b - Sigstore transparency entry: 207902511
- Sigstore integration time:
-
Permalink:
nielsrolf/dcache@6cff29caf6ab33979985cb928f66a6f0bba0d63f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nielsrolf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual_publish.yaml@6cff29caf6ab33979985cb928f66a6f0bba0d63f -
Trigger Event:
workflow_dispatch
-
Statement type: