On this page
Choose an instance lifetime๏
Beginner. Pick how long things live.
Existence |
One instance per |
Use it for |
|
|---|---|---|---|
๐ข |
|
Process (frame) |
Config, pools, caches |
๐ข |
|
Scope |
Request / session state |
๐ข |
|
Nothing โ new every meld |
Stateless workers, DTOs |
๐ก |
|
A scope and its children |
Shared context down a tree |
๐ก |
|
A request-local space |
Ephemeral request scoping |
๐ก |
Nothing โ leased from a pool the root keeps |
Costly objects reused across holders |
|
๐ |
|
A named group of scopes |
Cross-scope coordination |
The first three are the beginner set โ they cover most systems and need nothing but a static conjure. The rest arrive with the need that gives them meaning: lineage and spell spaces once you have nested scopes, managed pools once an object costs more to build than to lend, clusters once conduits link into groups.
For the intermediate leasing and release example, see Managed Spell Quantities.
Callables are always
unique. Want a fresh object every time? Bind a class asmany.
Runnable examples๏
Lifecycles unique vs many โ Beginner 02
Existence unique โ Beginner 13
Existence many โ Beginner 14
Existence unique per conduit โ Beginner 15
Many state isolation โ Beginner 29