@memberjunction/redis-provider 6.2.0-edge.3 → 6.2.0-edge.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,7 +52,7 @@ The `RedisProviderConfig` object supports the following options:
52
52
  | `url` | `string` | — | Redis connection URL (`redis://` or `rediss://` for TLS). Mutually exclusive with `options`. |
53
53
  | `options` | `RedisOptions` | — | Full [`ioredis` options](https://github.com/redis/ioredis#connect-to-redis) object. Mutually exclusive with `url`. |
54
54
  | `keyPrefix` | `string` | `'mj'` | Prefix for all Redis keys. Useful for isolating MJ data in a shared Redis instance. |
55
- | `defaultTTLSeconds` | `number` | `undefined` | Default time-to-live for all cached entries. `undefined` means keys persist until explicitly removed. |
55
+ | `defaultTTLSeconds` | `number` | `3600` | Default time-to-live for all cached entries. `0` means keys persist until explicitly removed. |
56
56
  | `maxRetries` | `number` | `10` | Maximum reconnection attempts with exponential backoff before giving up. |
57
57
  | `enableLogging` | `boolean` | `true` | Whether to log connection events via MJ's `LogStatus`/`LogError`. |
58
58
 
@@ -170,20 +170,37 @@ mj:DatasetCache:MyDataset_items
170
170
  mj:default:some-arbitrary-key
171
171
  ```
172
172
 
173
- ### Category Tracking
173
+ ### Index Groups
174
174
 
175
- Each category has an associated Redis Set at `{prefix}:__categories__:{category}` that tracks all member keys. This enables efficient:
175
+ A write can name an index group (`SetItem(key, value, category, { IndexGroup })`). The key is then
176
+ recorded in a Redis Set at `{prefix}:__group__:{category}:{group}`. `LocalCacheManager` passes the
177
+ entity name for every RunView cache entry, so any server can find the entries any other server wrote
178
+ for an entity:
176
179
 
177
- - **`ClearCategory()`** — Deletes all keys in a category in a single pipeline
178
- - **`GetCategoryKeys()`** — Lists all keys without scanning the entire keyspace
180
+ - **`GetIndexGroupKeys(category, group)`** — returns the group's keys that still exist, and removes
181
+ the ones that have expired from the set.
182
+ - The set is kept alive at least as long as its longest-lived member (an atomic Lua script that uses
183
+ only Redis 6-compatible commands).
184
+
185
+ There is no category-wide set. Expiry never removes set members, so such a set grows without bound
186
+ once keys carry a TTL. Category-wide operations use `SCAN` instead:
187
+
188
+ - **`ClearCategory()`** — deletes every key in the category, its index-group sets, and the
189
+ `{prefix}:__categories__:{category}` set that earlier versions of this provider maintained
190
+ - **`GetCategoryKeys()`** — lists every live key in the category (cost grows with the keyspace; meant
191
+ for administration)
179
192
 
180
193
  ### TTL (Time-to-Live)
181
194
 
182
195
  Redis has native key expiration, so TTL is handled efficiently at the server level:
183
196
 
184
- 1. **Config default** — `defaultTTLSeconds` applies to every `SetItem()` call
185
- 2. **Per-call override** — `SetItem(key, value, category, ttlSeconds)` overrides the default
186
- 3. **No TTL** — If neither is set, keys persist until explicitly removed or `ClearCategory()` is called
197
+ 1. **Config default** — `defaultTTLSeconds` applies to every `SetItem()` call. It defaults to **3600 (one hour)**.
198
+ 2. **Per-call override** — `SetItem(key, value, category, { TTLSeconds })` (or a bare number) overrides the default
199
+ 3. **No TTL** — `0`, either as the default or per call, stores the key without expiry
200
+
201
+ Event-driven invalidation stays the primary freshness mechanism. The TTL bounds how long an entry written by
202
+ something that never publishes (direct SQL, another application) can be served, and gives a `volatile-*`
203
+ eviction policy something to evict — Redis never evicts a key without an expiry under those policies.
187
204
 
188
205
  ### Error Handling
189
206
 
@@ -215,10 +232,11 @@ The interface is **generic-typed** — `T` flows from caller through to retrieve
215
232
  |--------|-------------|
216
233
  | `GetItem<T>(key, category?)` | Retrieves a cached value. **JSON-deserializes internally** — returns the typed object. Returns `null` on miss, corrupt entry, or Redis unavailability. |
217
234
  | `GetItems<T>(keys, category?)` | **Batched read via Redis `MGET`** — one command, one network round-trip, N values. Returns `Map<string, T \| null>`. Missing/corrupt entries map to `null` per-key without failing the batch. ~N× faster than individual `GetItem` calls which each pay full RTT. |
218
- | `SetItem<T>(key, value, category?, ttlSeconds?)` | Stores a value with optional TTL. **JSON-serializes internally** — pass plain objects/arrays/primitives. Uses pipeline for atomic set + category tracking. |
219
- | `Remove(key, category?)` | Deletes a key and removes it from category tracking. |
220
- | `ClearCategory(category)` | Deletes all keys in a category using the tracking Set. |
221
- | `GetCategoryKeys(category)` | Returns all key names in a category. |
235
+ | `SetItem<T>(key, value, category?, options?)` | Stores a value. `options` is `{ TTLSeconds?, IndexGroup? }` or a bare TTL number. **JSON-serializes internally** — pass plain objects/arrays/primitives. One pipeline for the write and the index-group update. |
236
+ | `Remove(key, category?)` | Deletes a key. Index-group membership is pruned the next time the group is read. |
237
+ | `ClearCategory(category)` | Deletes all keys in a category (found with `SCAN`) and the category's index-group sets. |
238
+ | `GetCategoryKeys(category)` | Returns all live key names in a category (`SCAN`). |
239
+ | `GetIndexGroupKeys(category, group)` | Returns the live keys written with that index group, pruning expired members. |
222
240
 
223
241
  **Internal serialization**: Redis stores strings, so `SetItem` calls `JSON.stringify(value)` and `GetItem` calls `JSON.parse(raw)` automatically. Callers see a typed object interface — no manual `JSON.parse`/`JSON.stringify` needed.
224
242
 
@@ -263,7 +281,38 @@ if (session) {
263
281
  | Property | Type | Description |
264
282
  |----------|------|-------------|
265
283
  | `IsConnected` | `boolean` | Whether the client has an active connection (transient — auto-reconnects). |
266
- | `Client` | `Redis` | The underlying `ioredis` client for advanced operations (pub/sub, streams, etc.). |
284
+ | `IsPubSubEnabled` | `boolean` | Whether the provider was created with `enablePubSub`. When `false`, the channel methods below do nothing. |
285
+ | `Client` | `Redis` | The underlying `ioredis` client, for commands the provider does not wrap (streams, etc.). Use the channel methods below for pub/sub. |
286
+
287
+ #### Named Channels (Application Pub/Sub)
288
+
289
+ Besides cache invalidation, the provider carries messages on channels you name. They use the provider's existing publisher and subscriber connections, so an application needs no Redis clients of its own.
290
+
291
+ | Method | Description |
292
+ |--------|-------------|
293
+ | `PublishMessage(channel, payload)` | Fire-and-forget. A failure is logged, never raised. |
294
+ | `PublishMessageAndWait(channel, payload)` | Resolves to the number of subscribers that received the message (`0` = nobody listening). Rejects if pub/sub is disabled or Redis rejects the publish. While disconnected it waits for the connection, so race it against a timeout if you need a deadline. |
295
+ | `SubscribeToChannel(channel, handler)` | Registers a handler (sync or async) and returns an unsubscribe function. Removing a channel's last handler unsubscribes it in Redis. |
296
+
297
+ ```typescript
298
+ const redis = new RedisLocalStorageProvider({ url: process.env.REDIS_URL, keyPrefix: 'myapp', enablePubSub: true });
299
+ await redis.StartListening();
300
+
301
+ // Every replica listens; the one that owns the request acts on it.
302
+ const stop = await redis.SubscribeToChannel('abort', (raw) => {
303
+ const { requestId, origin } = JSON.parse(raw) as { requestId: string; origin: string };
304
+ if (origin !== replicaId) abortLocally(requestId);
305
+ });
306
+
307
+ // Any replica can ask, and learns whether anyone heard it.
308
+ const receivers = await redis.PublishMessageAndWait('abort', JSON.stringify({ requestId, origin: replicaId }));
309
+ ```
310
+
311
+ Things to know:
312
+
313
+ - **Channels are prefixed.** `'abort'` becomes `myapp:abort`, so applications sharing one Redis under different key prefixes do not hear each other. The name `__pubsub__` is reserved for cache invalidation and is refused.
314
+ - **No echo suppression.** A process subscribed to a channel receives its own messages. Stamp an origin on the payload and check it, as above.
315
+ - **No replay.** Messages published while a subscriber is disconnected are never delivered to it.
267
316
 
268
317
  ## Testing
269
318
 
@@ -16,7 +16,7 @@
16
16
  import Redis from 'ioredis';
17
17
  import type { RedisOptions } from 'ioredis';
18
18
  import { ILocalStorageProvider } from '@memberjunction/core';
19
- import type { CacheChangedEvent } from '@memberjunction/core';
19
+ import type { CacheChangedEvent, LocalStorageWriteOptions } from '@memberjunction/core';
20
20
  /**
21
21
  * Configuration options for the Redis local storage provider.
22
22
  *
@@ -69,13 +69,30 @@ export interface RedisProviderConfig {
69
69
  keyPrefix?: string;
70
70
  /**
71
71
  * Default time-to-live in seconds applied to every `SetItem` call
72
- * unless overridden by the `ttlSeconds` parameter.
72
+ * unless the call passes its own TTL.
73
73
  *
74
- * Set to `0` or `undefined` to store keys without expiration (persistent).
74
+ * Event-driven invalidation stays the primary freshness mechanism; the TTL bounds how long
75
+ * an entry written by a process that never publishes (a direct SQL change, another
76
+ * application) can be served, and gives a `volatile-*` eviction policy something to evict —
77
+ * Redis never evicts a key without an expiry under those policies.
75
78
  *
76
- * @default undefined (no expiration)
79
+ * Set to `0` to store keys without expiration (persistent).
80
+ *
81
+ * @default 3600 (one hour)
77
82
  */
78
83
  defaultTTLSeconds?: number;
84
+ /**
85
+ * Expiry per category, overriding {@link defaultTTLSeconds} (0 = no expiry). **Merged over**
86
+ * the built-in `{ default: 0 }` rather than replacing it, so setting one category never
87
+ * changes another; name `default` here to override even that.
88
+ *
89
+ * The `default` category holds **proxy keys**: entries that vouch for other entries. The
90
+ * metadata snapshot's timestamps key is written after the payload it describes, and a dataset's
91
+ * `_date` key after its blob — so under one blanket TTL the proxy outlives what it vouches for,
92
+ * and a reader finds a freshness claim with nothing behind it. A server booting into that
93
+ * window adopted the timestamps and served empty metadata as current; the dataset check threw.
94
+ */
95
+ categoryTTLSeconds?: Readonly<Record<string, number>>;
79
96
  /**
80
97
  * Caps reconnection attempts. Past the cap ioredis stops reconnecting for the life of the
81
98
  * client, leaving the process cache-blind until it restarts.
@@ -113,6 +130,58 @@ export interface RedisProviderConfig {
113
130
  * @default false
114
131
  */
115
132
  enablePubSub?: boolean;
133
+ /**
134
+ * What a `set` or `removed` publishes, per category (the category `default` covers writes
135
+ * without one). `category_cleared` is always published in full.
136
+ *
137
+ * - `'full'` — the event carries the stored value in `Data`, so a subscriber can apply it
138
+ * without reading Redis. Right for categories whose values subscribers adopt (the RunView
139
+ * cache: engines apply the rows).
140
+ * - `'notice'` — the event names the key but carries no value. Right for large values that
141
+ * subscribers only need to know changed (the metadata snapshot: a server that hears about it
142
+ * re-checks its metadata against the database).
143
+ * - `'none'` — nothing is published.
144
+ *
145
+ * Categories not listed use {@link defaultPublishMode}.
146
+ */
147
+ publishModes?: Readonly<Record<string, CachePublishMode>>;
148
+ /**
149
+ * Publish mode for categories not named in {@link publishModes}.
150
+ * @default 'full' (every change carries its value — the behaviour before modes existed)
151
+ */
152
+ defaultPublishMode?: CachePublishMode;
153
+ }
154
+ /** How much a cache write publishes. See {@link RedisProviderConfig.publishModes}. */
155
+ export type CachePublishMode = 'full' | 'notice' | 'none';
156
+ /**
157
+ * Receives a message published on a named channel. May be async; a thrown error or rejected
158
+ * promise is logged and does not stop the other handlers on the channel.
159
+ */
160
+ export type ChannelMessageHandler = (message: string) => void | Promise<void>;
161
+ /**
162
+ * Thrown by {@link RedisLocalStorageProvider.WithKeyLock} when the lock could not be taken in
163
+ * time — distinct from anything `work` itself throws, so a caller can tell "another process is
164
+ * holding this slot" (fall back to invalidating it) from "my own read-modify-write is broken"
165
+ * (a bug, which must not be silently downgraded to an invalidation).
166
+ */
167
+ export declare class KeyLockTimeoutError extends Error {
168
+ readonly LockKey: string;
169
+ /**
170
+ * @param LockKey The lock that could not be taken.
171
+ * @param waitedMs How long the attempt waited.
172
+ * @param reason Why, when it was not contention — e.g. Redis being unreachable. Defaults to the
173
+ * contention message. The class (and so its `name`) is kept either way, because the caller's
174
+ * correct response is the same: do not write, invalidate instead.
175
+ */
176
+ constructor(LockKey: string, waitedMs: number, reason?: string);
177
+ }
178
+ /**
179
+ * Thrown when a held lock expired before its work finished — the work may have raced another
180
+ * writer, so its result must not be trusted.
181
+ */
182
+ export declare class KeyLockLostError extends Error {
183
+ readonly LockKey: string;
184
+ constructor(LockKey: string);
116
185
  }
117
186
  /**
118
187
  * Redis-backed implementation of the MemberJunction {@link ILocalStorageProvider} interface.
@@ -130,8 +199,11 @@ export interface RedisProviderConfig {
130
199
  * - **category** — maps to the MJ cache category (`RunViewCache`, `Metadata`, `DatasetCache`, etc.)
131
200
  * - **key** — the original key from the caller
132
201
  *
133
- * Categories are tracked in a Redis Set at `{prefix}:__categories__:{category}` so that
134
- * `ClearCategory()` and `GetCategoryKeys()` operations are efficient.
202
+ * Keys written with an `IndexGroup` are also recorded in a Redis Set at
203
+ * `{prefix}:__group__:{category}:{group}` (the RunView cache uses the entity name), which
204
+ * `GetIndexGroupKeys()` reads and prunes. `ClearCategory()` and `GetCategoryKeys()` walk the
205
+ * keyspace with `SCAN`; no category-wide set is kept, because expiry never removes set members
206
+ * and such a set grows without bound once keys carry a TTL.
135
207
  *
136
208
  * ### TTL Support
137
209
  *
@@ -171,10 +243,18 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
171
243
  * other wrote. See {@link ILocalStorageProvider.SupportsCrossProcessPersistence}.
172
244
  */
173
245
  readonly SupportsCrossProcessPersistence = true;
246
+ /**
247
+ * `true` — every process configured with the same URL and key prefix shares this keyspace.
248
+ * See {@link ILocalStorageProvider.SharedAcrossProcesses}.
249
+ */
250
+ readonly SharedAcrossProcesses = true;
174
251
  private _client;
175
252
  private _keyPrefix;
176
253
  private _defaultTTLSeconds;
254
+ private _categoryTTLSeconds;
177
255
  private _enableLogging;
256
+ /** Tokens of the leases this provider holds, so it releases only its own. */
257
+ private readonly _leaseTokens;
178
258
  private _connected;
179
259
  /** Ceiling on the reconnect delay. See {@link RedisProviderConfig.maxRetryDelayMs}. */
180
260
  private _maxRetryDelayMs;
@@ -215,6 +295,8 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
215
295
  private _channelHandlers;
216
296
  /** Fully-qualified channel name -> the subscribe still in flight, shared by concurrent callers. */
217
297
  private _pendingChannelSubscribes;
298
+ /** The subscriber start-up in flight or completed, shared by every caller of {@link StartListening}. */
299
+ private _listening;
218
300
  private _config;
219
301
  /**
220
302
  * Creates a new Redis local storage provider and establishes a connection.
@@ -373,6 +455,32 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
373
455
  * @internal
374
456
  */
375
457
  private buildCategorySetKey;
458
+ /**
459
+ * Builds the Redis Set key that indexes the keys written with one
460
+ * {@link LocalStorageWriteOptions.IndexGroup} in a category.
461
+ *
462
+ * Format: `{prefix}:__group__:{category}:{group}`
463
+ * @internal
464
+ */
465
+ private buildGroupSetKey;
466
+ /**
467
+ * Resolves the TTL for one write: the per-call value when given (a bare number is the legacy
468
+ * `ttlSeconds` argument), then the category's own expiry, then the configured default. `0`
469
+ * means no expiry.
470
+ * @internal
471
+ */
472
+ private resolveWriteOptions;
473
+ /**
474
+ * Lists every Redis key matching a glob pattern with `SCAN`, which never blocks the server
475
+ * the way `KEYS` does. Used only for category-wide operations, not on the per-save path.
476
+ * @internal
477
+ */
478
+ private scanKeys;
479
+ /**
480
+ * Deletes Redis keys in fixed-size batches so one call never sends an unbounded argument list.
481
+ * @internal
482
+ */
483
+ private deleteKeys;
376
484
  /**
377
485
  * Retrieves a value from Redis by key and optional category.
378
486
  *
@@ -416,29 +524,30 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
416
524
  * lose their prototype on retrieval; functions, Maps, Sets, and Dates have JSON's
417
525
  * usual limitations.
418
526
  *
419
- * If a `ttlSeconds` is provided, the key will automatically expire after that
420
- * duration. Otherwise, the configured `defaultTTLSeconds` is used. If neither
421
- * is set, the key persists indefinitely.
527
+ * The key expires after the per-call TTL when one is given, otherwise after the configured
528
+ * `defaultTTLSeconds`. If neither is set (or the value is `0`), the key persists indefinitely.
422
529
  *
423
- * The key is also added to a Redis Set that tracks all keys in the category,
424
- * enabling efficient `ClearCategory()` and `GetCategoryKeys()` operations.
530
+ * When the options carry an `IndexGroup`, the key is also added to that group's Redis Set so
531
+ * {@link GetIndexGroupKeys} can find it. The set is kept alive at least as long as its
532
+ * longest-lived member. There is no category-wide set: one would grow for ever once keys
533
+ * expire, because expiry never removes set members. Category-wide operations use `SCAN`.
425
534
  *
426
535
  * @typeParam T - Type of the value being stored. Caller-controlled.
427
536
  * @param key - The key to store under
428
537
  * @param value - The value to store (will be JSON-serialized internally)
429
538
  * @param category - Optional category for key isolation (defaults to `"default"`)
430
- * @param ttlSeconds - Optional time-to-live in seconds. Overrides `defaultTTLSeconds` from config.
539
+ * @param options - Expiry and index group. A bare number is accepted as the TTL in seconds.
431
540
  *
432
541
  * @example
433
542
  * ```typescript
434
543
  * // Store with default TTL
435
544
  * await provider.SetItem('view:users', { results, maxUpdatedAt }, 'RunViewCache');
436
545
  *
437
- * // Store with explicit 10-minute TTL
438
- * await provider.SetItem('view:users', { results }, 'RunViewCache', 600);
546
+ * // Store with explicit 10-minute TTL, indexed under the entity name
547
+ * await provider.SetItem('Users|…', { results }, 'RunViewCache', { TTLSeconds: 600, IndexGroup: 'Users' });
439
548
  * ```
440
549
  */
441
- SetItem<T>(key: string, value: T, category?: string, ttlSeconds?: number): Promise<void>;
550
+ SetItem<T>(key: string, value: T, category?: string, options?: number | LocalStorageWriteOptions): Promise<void>;
442
551
  /**
443
552
  * Removes a key from Redis and from its category tracking set.
444
553
  *
@@ -452,10 +561,11 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
452
561
  */
453
562
  Remove(key: string, category?: string): Promise<void>;
454
563
  /**
455
- * Clears all keys belonging to a specific category.
564
+ * Clears all keys belonging to a specific category, together with the category's index-group
565
+ * sets and the category set older versions of this provider maintained.
456
566
  *
457
- * Uses the category tracking Set to find all member keys, deletes them
458
- * in a single pipeline call, then removes the tracking Set itself.
567
+ * Keys are found with `SCAN`, so the operation also removes keys a peer wrote and keys whose
568
+ * index entry was lost.
459
569
  *
460
570
  * @param category - The category to clear. If empty, clears the `"default"` category.
461
571
  *
@@ -467,11 +577,27 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
467
577
  */
468
578
  ClearCategory(category: string): Promise<void>;
469
579
  /**
470
- * Returns all keys belonging to a specific category.
580
+ * {@link ClearCategory}, but reporting what happened instead of swallowing it. An administrator
581
+ * running `mj cache clear` needs to know a category did NOT go: the old path logged (with
582
+ * logging off, by default, in the CLI) and returned normally, so the command printed a key
583
+ * count and "servers will reload" for a clear that never happened.
471
584
  *
472
- * Reads from the category tracking Set, so the result reflects keys
473
- * that were added via `SetItem` (some may have expired via TTL but
474
- * will still appear in the set until cleaned up).
585
+ * While Redis is unreachable the clear is recorded for the reconnect flush and reported as not
586
+ * done — the flush will clear it, but reporting success now would be exactly the lie this
587
+ * method exists to stop.
588
+ *
589
+ * @returns Ok, plus the error when it failed.
590
+ */
591
+ ClearCategoryChecked(category: string): Promise<{
592
+ Ok: boolean;
593
+ Error?: string;
594
+ }>;
595
+ /**
596
+ * Returns all live keys belonging to a specific category.
597
+ *
598
+ * Walks the keyspace with `SCAN`, so the cost grows with the whole keyspace. Meant for
599
+ * administration and diagnostics; per-entity lookups on the save path use
600
+ * {@link GetIndexGroupKeys}.
475
601
  *
476
602
  * @param category - The category to list keys from
477
603
  * @returns Array of original key names (without the Redis prefix/category prefix)
@@ -483,6 +609,67 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
483
609
  * ```
484
610
  */
485
611
  GetCategoryKeys(category: string): Promise<string[]>;
612
+ /**
613
+ * Returns the keys written to `category` with `IndexGroup = group` that still exist.
614
+ *
615
+ * Members whose key has expired or been removed are dropped from the group set as a side
616
+ * effect, so the set shrinks back to the live keys whenever it is read. The read and the prune
617
+ * are one Lua script: a peer's `SADD` cannot land between them and be pruned unseen.
618
+ *
619
+ * @param category - The category the keys were written to
620
+ * @param group - The index group (for the RunView cache, the entity name)
621
+ * @returns The live keys, without the Redis prefix/category prefix
622
+ */
623
+ GetIndexGroupKeys(category: string, group: string): Promise<string[]>;
624
+ /**
625
+ * Runs `work` holding an exclusive lock on `key` across every process sharing this keyspace.
626
+ *
627
+ * The lock is `SET {prefix}:__lock__:{category}:{key} <token> NX PX 10000`, retried every 20 ms
628
+ * for up to 5 s, and released only by its holder (compare-and-delete). The 10 s expiry frees a
629
+ * lock whose holder died; `work` is expected to be a short read-modify-write.
630
+ *
631
+ * @throws when the lock is not acquired in time; `work` has not run
632
+ */
633
+ WithKeyLock<T>(key: string, category: string, work: () => Promise<T>): Promise<T>;
634
+ /** Extends this holder's lock. @internal */
635
+ private renewLock;
636
+ /**
637
+ * Whether this holder's token is still the one in the lock.
638
+ *
639
+ * @param confirmedAt when the lock was last known to be ours (acquisition, or the most recent
640
+ * renewal that actually landed)
641
+ *
642
+ * This used to answer `true` when the read failed, on the reasoning that an unreadable check
643
+ * should not fail a write. But the failures are correlated: this read and the renewals share
644
+ * one connection, so a read that throws means the renewals have been throwing too, and the
645
+ * lock is most likely expired — the one case where "still mine" is both unverifiable and
646
+ * probably false. The clock is the evidence that remains: a lock cannot outlive its TTL
647
+ * measured from the last time we know it was ours.
648
+ * @internal
649
+ */
650
+ private stillHoldsLock;
651
+ /**
652
+ * Claims `{prefix}:__lease__:{name}` for `ttlMs` with `SET NX PX`, so one process in the fleet
653
+ * runs a periodic job per period. The lease is not released; it expires.
654
+ */
655
+ TryAcquireLease(name: string, ttlMs: number): Promise<boolean>;
656
+ /**
657
+ * Extends a lease this provider holds, without being able to extend anyone else's: the script
658
+ * only acts when the stored token is this provider's. A lease that has already expired and been
659
+ * taken by another process is NOT stolen back — the caller learns it lost its turn.
660
+ *
661
+ * @returns true when this process still holds the lease afterwards.
662
+ */
663
+ RenewLease(name: string, ttlMs: number): Promise<boolean>;
664
+ /** Ends a lease this provider claimed, if it still holds it (compare-and-delete). */
665
+ ReleaseLease(name: string): Promise<void>;
666
+ private leaseKey;
667
+ /** @internal */
668
+ private acquireLock;
669
+ /** @internal */
670
+ private releaseLock;
671
+ /** Logs any per-command failure a pipeline reported; `exec()` itself does not throw for them. @internal */
672
+ private logPipelineErrors;
486
673
  /**
487
674
  * Whether the Redis client currently has an active connection.
488
675
  *
@@ -498,11 +685,15 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
498
685
  * category tracking. Prefer the `ILocalStorageProvider` methods for
499
686
  * standard operations.
500
687
  *
688
+ * For pub/sub, use {@link PublishMessage}, {@link PublishMessageAndWait} and
689
+ * {@link SubscribeToChannel} instead: they share the provider's subscriber connection and
690
+ * namespace channels with the key prefix.
691
+ *
501
692
  * @example
502
693
  * ```typescript
503
- * // Use for Redis-specific commands like pub/sub, streams, etc.
694
+ * // Use for Redis-specific commands the provider does not wrap, such as streams
504
695
  * const client = provider.Client;
505
- * await client.publish('cache-invalidation', 'entity:Users');
696
+ * await client.xadd('audit-events', '*', 'type', 'login');
506
697
  * ```
507
698
  */
508
699
  get Client(): Redis;
@@ -582,7 +773,8 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
582
773
  * a client in subscribe mode cannot execute other commands).
583
774
  *
584
775
  * Must be called explicitly after construction. No-op if `enablePubSub` is `false`
585
- * in the config, or if already listening.
776
+ * in the config. Concurrent and repeated calls share one start-up; if it fails, the
777
+ * subscriber is discarded and the next call starts a fresh one.
586
778
  *
587
779
  * @example
588
780
  * ```typescript
@@ -599,6 +791,18 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
599
791
  * ```
600
792
  */
601
793
  StartListening(): Promise<void>;
794
+ /**
795
+ * Creates the subscriber connection and subscribes it to the cache-invalidation channel.
796
+ *
797
+ * The message listener is attached before subscribing, so nothing that arrives is missed. On
798
+ * failure the connection is closed and cleared. A retry does not depend on that —
799
+ * {@link StartListening} resets its own in-flight promise and opens a fresh subscriber — but the
800
+ * failed client would otherwise stay open, reconnecting in the background with unlimited retries,
801
+ * and once it got back in it would resubscribe and deliver every invalidation a second time.
802
+ */
803
+ private openSubscriber;
804
+ /** Closes a subscriber that failed to start, and clears it if it is still the current one. */
805
+ private discardSubscriber;
602
806
  /**
603
807
  * Creates the subscriber Redis client, mirroring the main client's connection config.
604
808
  * @internal
@@ -626,27 +830,62 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
626
830
  * @internal
627
831
  */
628
832
  private publishChange;
833
+ /** The configured publish mode for a category. @internal */
834
+ private publishModeFor;
629
835
  /**
630
836
  * Publishes an arbitrary message on a named channel. Fire-and-forget: the promise is not
631
837
  * awaited and a failure is logged rather than raised, so a caller on a hot path is never
632
- * blocked or broken by the message bus.
838
+ * blocked or broken by the message bus. Does nothing when pub/sub is disabled.
839
+ *
840
+ * Use {@link PublishMessageAndWait} when the caller needs to know whether the message went out.
633
841
  *
634
842
  * The channel is namespaced with the provider's key prefix, so several applications can share
635
843
  * one Redis without hearing each other.
636
844
  *
637
845
  * @param channel Logical channel name (unprefixed).
638
846
  * @param payload Message body. Serialize before calling — this layer is shape-agnostic.
847
+ * @throws If `channel` is the name reserved for cache invalidation.
639
848
  */
640
849
  PublishMessage(channel: string, payload: string): void;
850
+ /**
851
+ * Publishes a message on a named channel and waits for Redis to accept it.
852
+ *
853
+ * Use this instead of {@link PublishMessage} when the caller must report honestly whether the
854
+ * message went out — for example, telling a user whether a cancellation reached the server
855
+ * running their request.
856
+ *
857
+ * While the connection is down the publish waits for it to come back rather than failing, so a
858
+ * caller that needs a deadline should race it against a timeout.
859
+ *
860
+ * @param channel Logical channel name (unprefixed), namespaced as in {@link PublishMessage}.
861
+ * @param payload Message body. Serialize before calling — this layer is shape-agnostic.
862
+ * @returns The number of subscribers that received the message, across every process sharing
863
+ * the Redis — including this one, if it subscribes to the same channel. Zero means the
864
+ * message was published but nobody was listening.
865
+ * @throws If pub/sub is disabled, if `channel` is reserved, or if Redis rejects the publish.
866
+ */
867
+ PublishMessageAndWait(channel: string, payload: string): Promise<number>;
641
868
  /**
642
869
  * Registers a handler for messages on a named channel, starting the subscriber if needed.
643
870
  *
871
+ * When pub/sub is disabled this registers nothing and returns an inert unsubscribe; check
872
+ * {@link IsPubSubEnabled} to tell that apart from a live subscription.
873
+ *
644
874
  * No echo suppression happens here — this layer does not know the payload shape. A publisher
645
875
  * that needs it must stamp its own origin on the message and check it in the handler.
646
876
  *
647
- * @returns A function that removes this handler.
877
+ * Redis does not replay messages, so anything published while the subscriber is disconnected
878
+ * is never delivered.
879
+ *
880
+ * @param channel Logical channel name (unprefixed), namespaced as in {@link PublishMessage}.
881
+ * @param handler Called with each message body. May be async.
882
+ * @returns A function that removes this handler. When the last handler on a channel is
883
+ * removed, the provider unsubscribes from it in Redis.
884
+ * @throws If `channel` is reserved, or if Redis rejects the subscribe.
648
885
  */
649
- SubscribeToChannel(channel: string, handler: (message: string) => void): Promise<() => void>;
886
+ SubscribeToChannel(channel: string, handler: ChannelMessageHandler): Promise<() => void>;
887
+ /** Whether the provider was created with `enablePubSub`. When false, the channel methods do nothing. */
888
+ get IsPubSubEnabled(): boolean;
650
889
  /**
651
890
  * The handler set for a channel, subscribing first when no caller has yet.
652
891
  *
@@ -664,9 +903,29 @@ export declare class RedisLocalStorageProvider implements ILocalStorageProvider
664
903
  * with nothing surfaced.
665
904
  */
666
905
  private subscribeChannel;
906
+ /**
907
+ * Removes one handler, and unsubscribes the channel in Redis when it was the last.
908
+ *
909
+ * Safe to call more than once. A handler set that is no longer the channel's current one
910
+ * belongs to a subscription already released, so it never triggers a second unsubscribe. A
911
+ * subscribe that arrives while the unsubscribe is in flight is queued behind it on the same
912
+ * connection, so the channel ends up subscribed.
913
+ */
914
+ private removeChannelHandler;
667
915
  /** Routes an inbound message to the handlers registered for its channel. @internal */
668
916
  private dispatchChannelMessage;
669
- /** Namespaces a channel with the provider's key prefix. @internal */
917
+ /**
918
+ * Runs one handler, containing a throw or a rejected promise so the other handlers still run.
919
+ *
920
+ * Failures are logged even when `enableLogging` is off: that setting quiets connection noise,
921
+ * and a failing handler is a defect in the consumer that would otherwise vanish.
922
+ */
923
+ private invokeChannelHandler;
924
+ /**
925
+ * Namespaces a channel with the provider's key prefix.
926
+ * @throws If the result is the channel reserved for cache invalidation, where a message would
927
+ * be read as a cache change by every server.
928
+ */
670
929
  private qualifyChannel;
671
930
  /**
672
931
  * Registers a callback for cache change events from other servers.
@@ -1 +1 @@
1
- {"version":3,"file":"RedisLocalStorageProvider.d.ts","sourceRoot":"","sources":["../src/RedisLocalStorageProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAuB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;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