RulePlanCache
final class RulePlanCache
Worker-lifetime LRU cache of compiled rule plans.
Plans are keyed by the normalized rule definition (string-only arrays). Plans are pure data — safe to cache across requests. A cached null-equivalent (un-cacheable) is represented by returning null from get(), not stored.
Bounded by $maxSize with LRU eviction. Typical apps have <1000 unique rules; the cap prevents pathological growth in apps that dynamically generate rules.
Constants
| private DEFAULT_MAX_SIZE |
|
Methods
Get a cached plan for the given rule array.
Set the maximum cache size. Intended for tests.
Flush all static state.
Details
at line 44
static AttributePlan|null
get(array $rules)
Get a cached plan for the given rule array.
Returns null if the rules contain non-string elements (un-cacheable) or if no cached plan exists.
at line 66
static void
put(array $rules, AttributePlan $plan)
Store a compiled plan in the cache.
at line 97
static void
setMaxSize(int $size)
Set the maximum cache size. Intended for tests.
Tests only. The cache size persists in a static property for the worker lifetime and affects every subsequent validation rule plan cache write.
at line 127
static void
flushState()
Flush all static state.