Skip to content

#53 - Load the cache adapters lazily from a service locator indexed by code - #54

Merged
njoubert-cleverage merged 1 commit into
mainfrom
53
Oct 15, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
53

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #53. Same model as process-bundle#276 (TransformerLocatorCompilerPass / TransformerRegistry), cleverage/rest-process-bundle#59 and cleverage/soap-process-bundle#53.

  • RegisterAdaptersPass: the services tagged cleverage.cache.adapter with a code attribute (- { name: cleverage.cache.adapter, code: memory }) are registered in a service locator, passed to AdapterRegistry (new optional constructor argument): an adapter is only instantiated when a task uses it. Duplicate or empty codes fail the container compilation, with the service ids.
  • A service tagged without code is still registered with AdapterRegistry::addAdapter() (eager), now deprecated since 2.3: the code will be required in 3.0.
  • AdapterRegistry::getAdapter() checks that the service implements AdapterInterface and that its getCode() returns the code of the tag; new hasAdapter() and getAdapters() (instantiates every adapter), as the client registries of the rest and soap bundles.
  • New #[AsCacheAdapter(code: '...')] attribute (registerAttributeForAutoconfiguration()), adding the tag with its code. AdapterInterface itself is not autoconfigured: it would tag twice the MemoryAdapter of the demo (loaded by the App\ resource and redefined in another service), see the issue.
  • Require symfony/service-contracts (ServiceProviderInterface, already installed through process-bundle).
  • Docs: code attribute in every example, registration notes.

Checked in process-bundle-demo (patch applied to the vendor), the 6 demo.cache.* processes:

  • current declaration (no code): same exit codes as on main (the three failures are expected by these demos), deprecations logged;
  • with the code attribute on the memory adapter: same exit codes, no deprecation, lint:container OK.

Tests with coverage (pcov): 100% lines, no risky test.

The demo declaration will be updated in a demo PR (the code attribute is ignored by the previous versions).

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

None: the adapters tagged without code keep working, with a deprecation (2.3, removal in 3.0). Behaviour change: the adapters with a code are no longer instantiated with the registry.

🤖 Generated with Claude Code

…y code

- RegisterAdaptersPass: the services tagged cleverage.cache.adapter with a
  code attribute are registered in a service locator passed to the
  AdapterRegistry (new optional constructor argument): an adapter is only
  instantiated when a task uses it. Duplicate or empty codes fail the
  container compilation. Without code, the adapter is still registered with
  addAdapter(), now deprecated (the code will be required in 3.0).
- AdapterRegistry: getAdapter() checks that the service implements
  AdapterInterface and that its getCode() is the code of the tag; new
  hasAdapter() and getAdapters() (instantiates every adapter), as the
  client registries of the rest and soap bundles.
- New #[AsCacheAdapter(code: '...')] attribute (autoconfiguration), adding
  the tag with its code.
- Require symfony/service-contracts (ServiceProviderInterface).
- Docs: code attribute in every example, registration notes.

Same model as process-bundle#276 (TransformerRegistry), rest#58 and soap#52.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@njoubert-cleverage
njoubert-cleverage merged commit 657f43d into main Oct 15, 2026
18 checks passed
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.

Load the cache adapters lazily from a service locator indexed by code

1 participant