Skip to content

Package-provided default cache settings per function - #20

Merged
lkdvos merged 2 commits into
mainfrom
preferences
Oct 14, 2026
Merged

lkdvos merged 2 commits into
mainfrom
preferences

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Closes #19.

Adds an overloadable hook, MemoizationKit.default_cache_settings(f), so a package can ship default cache settings for its own functions without writing to the user's preferences or overriding them from __init__:

MemoizationKit.default_cache_settings(::typeof(device_treebraider)) = (; measure = "bytes", maxsize = 2^28)

Resolution order:

set_cache_size! > [<Pkg>.MemoizationKit.<f>] > [<Pkg>.MemoizationKit] > default_cache_settings(f) > [MemoizationKit] > built-in

Package defaults take precedence over the global [MemoizationKit] section, so a generic user limit does not override a smaller limit a package chose (e.g. for device memory), while package- and function-specific preferences still do.

Open points from the issue:

  • Precedence: placed above the global section, as discussed above.
  • Package-wide hook: not added. Module values can't be distinguished by dispatch, so default_cache_settings(::Module) couldn't be specialized per package; a union method such as ::Union{typeof(f), typeof(g)} covers several functions instead.
  • Extension timing: settings are read when the first cache is created, as with preferences; this is documented.

Other changes:

  • The SQLite extension uses the same resolution, so the hook also applies to disk and disk_path.
  • Unknown or invalid package defaults throw an ArgumentError on the first call, since they are a bug in the package; invalid preferences are still ignored with a warning, whose text now says "setting" instead of "preference".
  • Documentation added in the configuration guide and the API reference.

🤖 Generated with Claude Code

`MemoizationKit.default_cache_settings(f)` lets a package ship defaults for
its own functions. They take precedence over the global `[MemoizationKit]`
preferences, while the package and per-function preference sections still
override them.

Closes #19

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lkdvos
lkdvos merged commit 4157648 into main Oct 14, 2026
11 checks passed
@lkdvos
lkdvos deleted the preferences branch October 14, 2026 18:58
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.

Package-provided default cache settings per function

1 participant