How grantjenks/python-diskcache works
DiskCache is a pure-Python, disk-backed caching library. A caller uses its Cache API to store or retrieve values; the cache serializes keys and values and persists cache records in SQLite, with file storage available for values. The library also provides sharded and Django-compatible cache APIs, persistent deque and mapping containers, and synchronization and memoization recipes. The README documents eviction policies, tags, and cross-process safety; the sampled excerpts support the core storage and wrapper relationships, but not every internal implementation detail.
Main entry points: core.py Cache API · fanout.py Fanout Cache · djangocache.py Django Backend · persistent.py Persistent Deque
Components 15
Cache and Storage
- Cache API
diskcache/core.py - Disk Serialization
diskcache/core.py - SQLite Database
- File Storage
Cache Interfaces
- Fanout Cache
diskcache/fanout.py - Django Backend
diskcache/djangocache.py - Public Exports
diskcache/__init__.py
Persistent Containers
- Persistent Deque
diskcache/persistent.py - Persistent Index
diskcache/persistent.py
Recipes and Coordination
- Cache Recipes
diskcache/recipes.py - Stampede Memoization
diskcache/recipes.py - Locks and Semaphores
diskcache/recipes.py - Request Throttling
diskcache/recipes.py
Other components
- Application
- Django
Connections 22
- Application → Public Exports: imports
- Application → Cache API: uses
- Cache API → Disk Serialization: serializes
- Cache API → SQLite Database: reads and writes
- Cache API → File Storage: stores files
- Application → Fanout Cache: uses
- Fanout Cache → Cache API: dispatches shards
- Django → Django Backend: provides backend API
- Application → Django Backend: uses
- Django Backend → Fanout Cache: delegates cache calls
- Application → Persistent Deque: uses
- Persistent Deque → Cache API: stores items
- Application → Persistent Index: uses
- Persistent Index → Cache API: stores mappings
- Application → Stampede Memoization: uses
- Stampede Memoization → Cache API: reads and writes results
- Application → Locks and Semaphores: uses
- Locks and Semaphores → Cache API: coordinates through
- Application → Request Throttling: uses
- Request Throttling → Cache API: tracks rate state
- Application → Cache Recipes: uses
- Cache Recipes → Cache API: uses cache