Skip to main content

derpcache

derpcache is a simple pickle-based caching utility.

It's made for people who love nuking their Jupyter kernels.

from derpcache import cache
import requests

countries = [
    'Afghanistan',
    'Albania',
    # ...
    'Zambia',
    'Zimbabwe'
]

pages = []
for country in countries:
    url = f'https://en.wikipedia.org/wiki/{country}'
    annotation = f'Wikipedia page for {country}'
    page = cache(requests.get, url, _annotation=country)
    pages.append(page)

Why should I use derpcache?

  • You want a cache that will persist between kernel restarts.
  • You want a simple functional interface—no IPython magics needed.
  • You want a reasonable amount of visibility into what's in your cache.
  • You want the ability to set expiration rules.

Expiration

>>> import time
>>> def long_running_func(*args, **kwargs):
...     time.sleep(1200)
...     print('running...')
...     return 'done'
...
>>> expires_after = 300
>>> cache(long_running_func, _expires_after=expires_after)
running...
done
>>> cache(long_running_func)
done
>>> time.sleep(expires_after)
>>> cache(long_running_func)
running...
done

Viewing cached entries

from derpcache import get_index
from pprint import pprint

pprint(get_index(), sort_dicts=False)  # or, pandas.DataFrame.from_records
{"5e39b292": {"callable": "__main__.long_running_func",
              "called_at": "2022-09-06T05:19:14.614796"},
 "b37ab1af": {"callable": "requests.api.get",
              "called_at": "2022-09-06T05:21:35.157183",
              "annotation": "Afghanistan"},
 "f0103017": {"callable": "requests.api.get",
              "called_at": "2022-09-06T05:21:35.814452",
              "annotation": "Albania"},
 "8861f226": {"callable": "requests.api.get",
              "called_at": "2022-09-06T05:21:36.084777",
              "annotation": "Zambia"},
 "19754ec0": {"callable": "requests.api.get",
              "called_at": "2022-09-06T05:21:36.341655",
              "annotation": "Zimbabwe"}}

Metadata

Release files for derpcache 0.1.0

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

Source distribution (sdist)

Source distribution for derpcache 0.1.0
File Size Uploaded Provenance Actions
derpcache-0.1.0.tar.gz 19.2 kB Without provenance Details for derpcache-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 38.7 kB

Release files / derpcache-0.1.0.tar.gz

Download URL derpcache-0.1.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8fd0432f39ff32e4560ad1a91e8b791ebf0ffa870e9ee696b6c4abc9ff55c08b
BLAKE2b-256 checksum
How to use checksums
3eb0d36a5d55ebcfecb406b1c4dfd4f3edd78e827edad74e584e472d7a471881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / derpcache-0.1.0-py3-none-any.whl

Download URL derpcache-0.1.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22559ca7d72e3458ba0e646c99baa65f8031c5af647dd94b71ccaa8ea146969f
BLAKE2b-256 checksum
How to use checksums
e8b81adcf8d48c544de05ba079d2cb01bd3d1df5f9e39b53652d8ec8e2f59915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Security for derpcache 0.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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