content.cache

The resolved cache backing the instance, storing parsed bodies and snapshots.

content.cache

The resolved Cache backing the instance. Its methods store parsed bodies and produce snapshot artifacts.

MethodSignatureDescription
get(key: string) => Promise<T | null>Read a cached value by <source>:<path> key.
set(key: string, value: T) => Promise<void>Write a value into the cache.
keys(prefix?: string) => Promise<string[]>List keys, optionally scoped to one source. Derived from the manifest, so it works on key-less drivers.
refresh(source: string) => Promise<ContentFile[]>Re-read a whole source, reconcile the manifest, return the fresh files.
invalidate(key: string) => Promise<void>Remove one entry so the next get() re-parses it.
expire(key: string) => Promise<void>Mark one entry stale (served under swr while it refreshes).
manifest(opts?: CacheArtifactOptions) => Promise<CacheArtifact | null>Produce the manifest artifact. fresh: true (the default) runs init() first so it reflects the source; fresh: false returns the persisted index artifact from the driver (used by init()), or null when absent.
snapshot(source: string, opts?: CacheArtifactOptions) => Promise<CacheArtifact | null>Produce one source's snapshot artifact.

See Caching for refresh/invalidate/expire and Artifacts & hydration for manifest/snapshot.

Usage

usage.ts
await content.cache.invalidate('default:posts/hello.md')