Skip to content

Commit bc4ac7c

Browse files
docs(web/guides): fix singleton cache keying and case-sensitive name claims in DI usage guide
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent 2fb562d commit bc4ac7c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix two incorrect statements in the DI usage guide: singleton cache is keyed by binding name (not component path), and binding name lookup is case-insensitive on all supported engines.

web/sites/guides/src/content/docs/v4-0-0/digging-deeper/dependency-injection-usage.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ component extends="wheels.WheelsTest" {
6464
}
6565
```
6666

67-
Two things to know. First, the swap is global for the duration of the test — any code path that resolves `emailService` during that `it` block gets the fake, including model callbacks and background jobs that run inline. Second, because `asSingleton()` caches the first instance per component path, you want the fake under a *different* component path than the real one (`tests._assets.FakeEmailService` vs `app.lib.EmailService`) so the cache doesn't hand you a stale real instance.
67+
Two things to know. First, the swap is global for the duration of the test — any code path that resolves `emailService` during that `it` block gets the fake, including model callbacks and background jobs that run inline. Second, the singleton cache is keyed by the binding name; re-binding the name to a different component path invalidates the cached instance, so register the fake under its own component path (`tests._assets.FakeEmailService` vs `app.lib.EmailService`) and the container drops the stale real instance.
6868

6969
## Per-request resolvers
7070

@@ -241,7 +241,7 @@ When `service("name")` throws `Wheels.Injector` or hands back the wrong thing, r
241241

242242
- **Is the registration in `config/services.cfm`?** The file is loaded once at app start. Typos don't surface until resolution time.
243243
- **Did the app reload after you edited `services.cfm`?** Run `wheels reload` or hit `?reload=true&password=...`. Service registrations are *not* re-read per request.
244-
- **Does the binding name match exactly?** Names are case-sensitive. `service("EmailService")` and `service("emailService")` are different keys.
244+
- **Does the binding name match exactly?** Binding names are resolved via CFML struct keys, which are case-insensitive on Lucee, Adobe CF, and BoxLang — `service("EmailService")` and `service("emailService")` hit the same binding. If you're getting a resolution error, the name is a typo or the registration was never reached (a thrown error during app start can wipe the container — see [#3061](https://github.com/wheels-dev/wheels/issues/3061); reload after fixing the error).
245245
- **Is `.to(...)` pointing at a valid dotted path?** A typo in the target path throws at `createObject()` time, not at registration time. The error surfaces the first time someone resolves the name.
246246
- **Circular dependency?** If A's `init()` auto-wires B and B's `init()` auto-wires A, the injector throws `Wheels.DI.CircularDependency` with the resolution chain. Break the cycle by turning one side into a factory or resolving lazily.
247247

0 commit comments

Comments
 (0)