Skip to content

Add configure() and DISKCACHE_DISK so caches created without a disk use a process-wide default, with an explicit disk always winning - #24

Merged
avgvi merged 1 commit into
masterfrom
feat/configure-default-disk
Oct 18, 2026
Merged

avgvi merged 1 commit into
masterfrom
feat/configure-default-disk

Conversation

@avgvi

@avgvi avgvi commented Oct 18, 2026

Copy link
Copy Markdown
Member

Adds a process-wide default disk, so an application can turn on SafeDisk for caches that libraries create for it without patching those libraries.

  • configure(disk) sets the disk type of every Cache, FanoutCache, Deque, Index and DjangoCache created afterwards without a disk, returns the previous setting, and configure(None) clears it. default_disk() returns the type in effect.
  • Without configure, the environment decides: DISKCACHE_DISK=safe selects SafeDisk, with DISKCACHE_SAFE_TYPES (import paths) and DISKCACHE_SAFE_MODULES (module names) passed to SafeDisk.with_types; DISKCACHE_DISK also takes default or the import path of a disk class. Invalid values raise ValueError naming the variable.
  • Precedence: an explicit disk= argument, then configure, then the environment, then Disk. Libraries that pass their own disk keep it, caches that already exist keep theirs, and nothing is written to the cache directory.
  • The disk arguments of Cache, FanoutCache, Deque, Index and the Django DISK option now default to None, meaning that type.
  • Tests in tests/test_default_disk.py for every container, the precedence, the environment forms and errors, pickled caches and persistence.

Stacked on #23.

Verified: 484 tests pass on Python 3.12; blue, isort, flake8, mypy, doc8 and the Sphinx build with warnings as errors pass.

@read-the-docs-community

read-the-docs-community Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 diskcache-community | 🛠️ Build #35226541 | 📁 Comparing dc35bfd against latest (823b63a)

  🔍 Preview build  

7 files changed · ± 7 modified

± Modified

…se a process-wide default, with an explicit disk always winning.
@avgvi
avgvi force-pushed the feat/safedisk-with-types branch from 56cf9b9 to a12c6ab Compare October 18, 2026 19:14
@avgvi
avgvi force-pushed the feat/configure-default-disk branch from db65f75 to dc35bfd Compare October 18, 2026 19:14
Base automatically changed from feat/safedisk-with-types to master October 18, 2026 19:31
@avgvi
avgvi merged commit 8c8c270 into master Oct 18, 2026
23 of 45 checks passed
@avgvi
avgvi deleted the feat/configure-default-disk branch October 18, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant