API reference
Glacier.sync()
sync() reconciles cache state across edge locations so warmed and invalidated entries stay consistent no matter which region a user lands in.
Signature
glacier.sync(options?: SyncOptions): Promise<SyncResult>
Why you need it
In a single-region deployment, the cache is one thing in one place and always consistent. Across multiple edge regions, each node keeps its own warm set. Without coordination, a user who moves between regions — or whose request is routed to a different node — can hit a cold or stale cache.
sync() exchanges a compact digest of cache state between nodes and reconciles the differences: warming entries that are hot elsewhere, and dropping ones invalidated in another region.
Options
regions— limit the sync to specific regions instead of all of them.mode—'push'shares this node's state,'pull'adopts others','merge'(default) does both.
Example
Most apps never call sync() directly — Glacier runs it on an interval automatically. You'd call it manually after a large batch change that you want reflected everywhere immediately:
import { glacier } from '../glacier.config'
await glacier.invalidate('catalog')
const result = await glacier.sync({ mode: 'push' })
console.log(`Synced ${result.regions.length} regions`)
Return value
Resolves with a SyncResult describing which regions were reached and how many entries were warmed or dropped. See Observability for how to monitor sync activity in production.