Targeting & Caching
Per-subject targeting
Pass the user’s ID (or any numeric-based identifier) as subjectKey to
evaluator(). The value must match exactly what is stored in the allow/deny
lists in the Pluma UI; those lists are populated with known user IDs.
Evaluation precedence for each flag:
- Deny list — if
subjectKeyis indenyList, returnsfalseimmediately. - Allow list — if
subjectKeyis inallowList, returnstrueimmediately. - Rollout percentage — if set (not
null), a deterministic FNV-1a 32-bit hash ofsubjectKey:flagKeyassigns the subject to a bucket in[0, 100). Returnstrueif the bucket falls within the percentage. - Parent inheritance — if
inheritParentis set and the flag has a parent, evaluation walks up the parent chain. - Base enabled state — returns the flag’s
enabledvalue.
If subjectKey is omitted, steps 1–3 are skipped (allow/deny lists and rollout
are not evaluated). The flag resolves purely from parent inheritance and its
base enabled state.
Caching
PlumaSnapshotCache uses a lazy TTL-based cache (default 30 seconds). The
snapshot is fetched on the first evaluator() call and reused until the TTL
expires. There is no background polling.
- Create the cache once — at module level or in application startup. Creating a new instance per request defeats the cache entirely.
- The snapshot is not scoped to
subjectKey. One cached snapshot serves all subjects. - On refresh, the SDK sends the current snapshot version as an
If-None-Matchheader. The API returns304 Not Modifiedif nothing has changed, so bandwidth usage is minimal.
Parent flags
Flags can be organised into parent/child hierarchies. When a child flag has
inheritParent: true, evaluation walks up to the parent flag after the
allow/deny list and rollout checks on the child pass without a definitive
result.
The traversal is iterative (not recursive) and bounded by MAX_PARENT_DEPTH
(32). A cycle guard prevents infinite loops.