API reference

Glacier.invalidate()

invalidate() tells Glacier that some data has changed and the cached copy can no longer be trusted. It's keyed and tag-aware, so you only clear what actually changed.


Signature

glacier.invalidate(
  keyOrTag: string,
  ...args: any[]
): Promise<void>

Parameters

  • keyOrTag — either a query key or a tag. With just a key, the whole namespace is invalidated. With a key and arguments, only that specific entry is.
  • args — optional arguments identifying a single entry to invalidate.

Examples

Invalidate one entry after an update:

await api.updateUser(42, changes)
await glacier.invalidate('user', 42)

Invalidate an entire namespace:

await glacier.invalidate('user') // clears every cached user

Invalidate everything sharing a tag:

// Any query registered with tags: ['billing']
await glacier.invalidate('billing')

Invalidate, then optionally re-warm

By default, invalidated entries are simply dropped and re-fetched on next access. If you want the fresh value warmed immediately, follow up with prefetch().

Behavior

Invalidation is propagated across edge nodes so a user in another region doesn't get a stale copy. Until the new value is warmed, the next request for an invalidated entry falls through to the loader as a normal cold read.

Previous
Glacier.prefetch()