TagCache.set() method
Stores given value under a given key, tagging it with the given tags
The value is JSON-encoded, and the key is added to one redis set per tag so TagCache.invalidate() can find it later. Everything happens in a single MULTI, so a value is never visible without its tag membership.
When ttl is given it is applied to the value AND refreshed on each tag set, so tag sets do not outlive the entries they track. Without it, nothing expires and the entry lives until it is invalidated.
Signature:
set<_T = any>(key: string, value: any, tags: string[], ttl?: number): Promise<boolean>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
key |
string |
unprefixed key to store the value under |
|
value |
any |
data to store; must be JSON-serialisable |
|
tags |
string[] |
tags to mark the value with; any one of them can later invalidate it. An empty array stores the value with no tag, which makes it unreachable by TagCache.invalidate(). |
|
ttl |
number |
(Optional) optional time to live, in MILLISECONDS |
Returns:
Promise<boolean>
true once the write is committed, false if redis rejected it — the error 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.