DiskCache: Disk Backed CacheΒΆ
DiskCache is an Apache2 licensed disk and file backed cache library, written
in pure Python, and compatible with Django. It stores keys and values in a
SQLite database and in files next to it, is safe to share between threads and
processes, evicts by LRU, LFU and other policies, and ships Deque and
Index containers plus recipes for memoization, locks and throttling.
This documentation describes diskcache-community, a community fork of
python-diskcache. The fork is published on PyPI as diskcache-community
and imported as diskcache. It keeps the public API, the cache.db
schema and the file layout of the last upstream release, 5.6.3, so existing
cache directories keep working, and it carries the fix path for
CVE-2025-69872 through the opt-in SafeDisk.
The README in the repository explains why the fork exists and how to migrate.
Install it with pip, after removing the upstream diskcache package if it
is present:
$ pip uninstall diskcache
$ pip install diskcache-community
Start with the DiskCache Tutorial and keep the DiskCache API Reference at hand.
- DiskCache Tutorial
- DiskCache Cache Benchmarks
- DiskCache DjangoCache Benchmarks
- Case Study: Web Crawler
- Case Study: Landing Page Caching
- Talk: All Things Cached - SF Python 2017 Meetup
- Comparisons
- DiskCache API Reference
- Cache
- FanoutCache
- DjangoCache
- Deque
- Index
- Recipes
- Constants
- Disk
- JSONDisk
- SafeDisk
- Timeout
- ReadOnlyError
- DiskCache Development