Skip to content

Cache built block configs across requests (self-invalidating) - #72

Open
helmutkaufmann wants to merge 3 commits into
wintercms:mainfrom
helmutkaufmann:feat/config-cache
Open

Cache built block configs across requests (self-invalidating)#72
helmutkaufmann wants to merge 3 commits into
wintercms:mainfrom
helmutkaufmann:feat/config-cache

Conversation

@helmutkaufmann

Copy link
Copy Markdown
Contributor

Split out of #68 (closed in favor of smaller, focused PRs).

Summary

  • BlockManager::getConfigs() now stores built configs in Laravel's cache, keyed by a signature derived from every registered .block file's mtime (plugin-registered blocks and theme-provided blocks, scanned recursively so nested theme block subfolders are covered too).
  • The cache self-invalidates whenever a .block file is added, removed, or edited — no manual php artisan cache:clear needed.
  • A per-request in-memory memo additionally avoids recomputing the signature more than once per request.

See the README "Performance" section for details.

Test plan

  • New tests in tests/classes/BlockManagerTest.php covering in-request memoization, cross-request cache hits, and cache invalidation on both a plugin-block mtime change and a nested theme-block mtime change
  • Full plugin test suite passes (php artisan winter:test -p Winter.Blocks)

BlockManager::getConfigs() now stores built configs in the Laravel
cache, keyed by an md5 signature of every registered .block file's
mtime, plus a per-request in-memory memo. The cache self-invalidates
when any block file is added, removed, or edited.
blocksSignature() only globbed the top level of the theme's blocks
directory, so editing or adding a .block file in a theme subfolder
didn't change the signature and the cache kept serving stale data —
even though getBlocks() (Block::listInTheme()) does scan theme block
subfolders recursively. Switched to File::allFiles() so the signature
covers everything getBlocks() actually picks up.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@helmutkaufmann, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 28f8f0df-3200-4701-9bf4-9b99e7a1122c

📥 Commits

Reviewing files that changed from the base of the PR and between 394377b and 5bb46d6.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • README.md
  • classes/BlockManager.php
  • tests/classes/BlockManagerTest.php
  • tests/fixtures/classes/BlockManagerCacheTestDouble.php
  • updates/version.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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