Documentation / zerotal / cache / TaggedCache
Class: TaggedCache
Defined in: packages/cache/src/CacheManager.ts:190
Extends
Constructors
Constructor
new TaggedCache(
_driver,_prefix?,_defaultTtl?,_lock?,_stampedeProtection?):TaggedCache
Defined in: packages/cache/src/CacheManager.ts:19
Parameters
_driver
_prefix?
string = ""
_defaultTtl?
number
_lock?
LockManager | null
_stampedeProtection?
boolean = true
Returns
TaggedCache
Inherited from
Methods
get()
get<
T>(key):Promise<T|null>
Defined in: packages/cache/src/CacheManager.ts:49
Type Parameters
T
T
Parameters
key
string
Returns
Promise<T | null>
Inherited from
set()
set(
key,value,ttl?):Promise<void>
Defined in: packages/cache/src/CacheManager.ts:59
Parameters
key
string
value
unknown
ttl?
number
Returns
Promise<void>
Inherited from
forget()
forget(
key):Promise<void>
Defined in: packages/cache/src/CacheManager.ts:66
Parameters
key
string
Returns
Promise<void>
Inherited from
has()
has(
key):Promise<boolean>
Defined in: packages/cache/src/CacheManager.ts:72
Parameters
key
string
Returns
Promise<boolean>
Inherited from
flush()
flush():
Promise<void>
Defined in: packages/cache/src/CacheManager.ts:79
Returns
Promise<void>
Inherited from
remember()
remember<
T>(key,ttl,fn):Promise<T>
Defined in: packages/cache/src/CacheManager.ts:85
Type Parameters
T
T
Parameters
key
string
ttl
number
fn
() => T | Promise<T>
Returns
Promise<T>
Inherited from
forever()
forever(
key,value):Promise<void>
Defined in: packages/cache/src/CacheManager.ts:147
Parameters
key
string
value
unknown
Returns
Promise<void>
Inherited from
tags()
tags(
tagNames):TaggedCache
Defined in: packages/cache/src/CacheManager.ts:171
Scope reads/writes to a tag namespace. Tags are a deterministic, ordered
namespace: tags([...]) sorts and joins the names into a key prefix, so
tags(['a','b']) and tags(['b','a']) address the same entries (the order
no longer matters), and tags([...]).flush() clears exactly that namespace.
Note: this is namespacing, not a per-tag index — flushing tags(['b']) does
NOT invalidate entries written under tags(['a','b']). Flush with the same
tag set you wrote with. (A true multi-tag index — where any one tag can
invalidate every entry carrying it — is intentionally out of scope for v1.)
The namespace is a fixed-length digest of the sorted tag list rather than the names
joined together, because flush() is a prefix delete and a joined prefix contains its
own sub-namespaces: tags(['a']) produced a:, which matches a:b:key, so flushing
['a'] wiped the ['a','b'] namespace this docblock promises it will not. A digest
also stops a tag that happens to contain the separator from colliding —
tags(['a:b']) and tags(['a','b']) are different namespaces.
Parameters
tagNames
string[]
Returns
TaggedCache
Inherited from
dispose()
dispose():
void
Defined in: packages/cache/src/CacheManager.ts:185
Returns
void