PVCtx class

Execution context for a cache operation, passed through all hooks.

Contains operation state: initial values, runtime state, storage proxies, and return values.

Hooks can read/modify keys, values, metadata, and break execution with BreakHook.

EventFlow lifecycle:

  1. preProcess: Validation
  2. metaRead: Metadata loaded
  3. metaUpdatePriorEntry: Pre-entry updates
  4. storageRead/storageUpdate: Entry I/O
  5. metaUpdatePostEntry: Post-entry updates
  6. postProcess: Finalization

Example:

Future<void> myHook(PVCtx ctx) async {
  ctx.runtimeMeta['timestamp'] = DateTime.now().toIso8601String();
  if (shouldBreak) throw BreakHook(returnType: BreakReturnType.resolved);
}

Constructors

PVCtx({required PVCache cache, required ActionType actionType, String? initialKey, dynamic initialEntryValue, required Map<String, dynamic> initialMeta})
Create a new context for a cache operation.

Properties

actionType ActionType
The type of operation being performed (put, get, delete, clear, exists).
final
cache PVCache
The cache instance this operation belongs to.
final
entry PVCtxStorageProxy
Storage proxy for cache entries.
no setter
entryValue ↔ dynamic
Current value being operated on (modifiable by hooks).
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
initialEntryValue → dynamic
Initial value for put operations (null for others).
final
initialKey String?
Initial key provided to the operation (null for clear).
final
initialMeta Map<String, dynamic>
Initial metadata merged with PVCache.defaultMetadata.
final
meta PVCtxStorageProxy
Storage proxy for metadata.
no setter
resolvedKey String?
Resolved key for the entry (modifiable by hooks).
getter/setter pair
resolvedMetaKey String?
Resolved metadata key (modifiable by hooks).
getter/setter pair
returnValue ↔ dynamic
Value returned from the operation.
getter/setter pair
runtimeData Map<String, dynamic>
Temporary inter-hook communication storage (not persisted).
final
runtimeMeta Map<String, dynamic>
Runtime metadata loaded from storage and modified by hooks.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queue(List<PVCacheHook> hooks) Future<void>
Execute all hooks through the EventFlow lifecycle.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited