put method

Future<void> put(
  1. String key,
  2. dynamic value, {
  3. Map<String, dynamic>? metadata,
})

Store a value in the cache.

Executes hooks in EventFlow order. Metadata controls hook behavior (TTL, encryption, etc).

Example:

await cache.put('user:123', {'name': 'Alice'});
await cache.put('session', token, metadata: {'ttl_seconds': 3600});

Implementation

Future<void> put(
  String key,
  dynamic value, {
  Map<String, dynamic>? metadata,
}) async {
  final ctx = PVCtx(
    cache: this,
    actionType: ActionType.put,
    initialKey: key,
    initialEntryValue: value,
    initialMeta: metadata ?? {},
  );
  await ctx.queue(_orderedPutHooks);
}