Skip to content

[6.x] Fix cache misses for namespaced and subfolder fieldsets - #15666

Open
daun wants to merge 10 commits into
statamic:6.xfrom
daun:perf/addon-blueprint-cache
Open

daun wants to merge 10 commits into
statamic:6.xfrom
daun:perf/addon-blueprint-cache

Conversation

@daun

@daun daun commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

FieldsetRepository::find() keeps fieldsets in memory, but two kinds of handles never hit the cache:

  • Namespaced handles like vendor::name. The lookup uses Arr::get(), which turns : into .. So foo::bar is looked up as foo..bar, but it is stored as foo::bar.
  • Slash handles like sub/test. The lookup runs before / is normalized to ., while the store uses sub.test.

On a miss, the YAML file is read and parsed again. Blueprints call find() for every import: and every field: handle.field reference, so blueprints that import addon fieldsets re-parse them on every request. An example would be global set blueprints, which the cascade builds on every frontend request. In a custom addon, a global blueprint importing 12 namespaced fieldsets caused about 13 YAML parses per page request.

Changes

  • find() normalizes the handle, then looks it up as a plain array key
  • Once the cache actually works, entries can go stale, so we make sure that
    • save() stores the saved fieldset in the cache
    • delete() removes it
    • reset() removes it

Tests

  • Same instance is returned for plain, dot, slash and namespaced handles, including namespaced subfolders
  • Cache is correct after save(), delete() and reset()

Related

#13013 also adds cache updates to save()/delete(). The two PRs might conflict slightly there.

This branch has not been deployed

No deployments
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