TagCache.invalidate() method
Invalidates data under given tags
Collects every key held by the given tags, deletes those keys, and then removes them from all other tag sets so no tag is left pointing at a key that no longer exists.
Two properties worth knowing, because neither is obvious from the signature:
- **It resolves before the work is confirmed.** The deletion is dispatched as a
MULTIwhose result is not awaited — a failure is logged, not returned. So atrueresult means "the invalidation was issued", not "the keys are gone". Do not use it to order a subsequent read. - **The cleanup pass scans every tag**, not just the ones passed in, since a key may be held by tags other than those being invalidated. Cost therefore grows with the total number of tags in the keyspace rather than with the size oftags.
Signature:
invalidate(...tags: string[]): Promise<boolean>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
tags |
string[] |
one or more tags whose data should be dropped |
Returns:
Promise<boolean>
true if the invalidation was issued, including the case where the tags held no keys at all; false only if collecting the keys failed, which is logged rather than thrown
Exceptions
TypeError when there is no redis connection — see REDIS_INIT_ERROR
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.