Skip to content

feat: cache raw per-scope bags in front of database layers (phase 3) - #9

Merged
imanimanyara merged 2 commits into
mainfrom
feat/phase-3-caching
Nov 10, 2026
Merged

imanimanyara merged 2 commits into
mainfrom
feat/phase-3-caching

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

Phase 3 of the settings design: caching.

  • CachingDriver + SettingsCache cache each scope's raw rows under a hashed key of connection, database, tenant, store, table and scope. ULID generation tokens (scope, store, global epoch) are replaced after every write commits, so a Cache::flexible() stale-while-revalidate refresh can never restore an invalidated value. Misses are cached as empty bags.
  • Reads inside a transaction, or while bootstrap mode skips the layer, go straight to the database; a failing cache falls back to the database and is logged.
  • laranail::settings.warm and laranail::settings.clear-cache, plus warmCache() / clearCache() on a handle (gated by manage_stores, audited).
  • cache.* config (enabled true, app default store, ttl 3600, stale 300).
  • phpbench read benchmark (composer bench): ten keys through owner → team → global per request — uncached 3.81 ms / 10 queries, cold 2.22 ms / 1 query, warm 2.08 ms / 0 queries (array store).
  • Mutation testing now runs weekly and on dispatch only, not on pull requests (owner decision); a dispatch can name the files to mutate.

Checks run locally

  • Pest: 526 passed (2042 assertions); coverage 97.7 % (needs memory_limit=2G locally to write the report); mutation of the changed files 75.12 %
  • PHPStan max, Rector, Pint: clean
  • Guards proven red: connection and tenant in the key, token rotation (incl. the late-refresh race), transaction bypass, invalidation on flush and promote

Add CachingDriver and SettingsCache: each scope's rows are cached under a
hashed key of connection, database, tenant, store, table and scope, and
invalidated by replacing ULID generation tokens (scope, store, epoch) after
every write commits, so a Cache::flexible() refresh can never restore an
invalidated value. Misses are cached as empty bags; reads inside a
transaction or while bootstrap skips the layer go to the database; a failing
cache falls back and is logged.

Add laranail::settings.warm and .clear-cache, clearCache()/warmCache() on a
handle (manage_stores, audited), the cache.* config keys, a phpbench read
benchmark (composer bench), and docs. Mutation testing now runs weekly and
on dispatch only, not on pull requests.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

phpbench requires doctrine/annotations, which Packagist marks abandoned, so composer audit failed. phpbench now installs into tools/phpbench/ on the first composer bench, and the package's own dependency tree and audit stay clean.
@imanimanyara
imanimanyara merged commit a2eda82 into main Nov 10, 2026
15 checks passed
@imanimanyara
imanimanyara deleted the feat/phase-3-caching branch November 11, 2026 17:52
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.

2 participants