MikroOrmCache
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:84
MikroORM-backed IVersionedCache: one row per key in the table mapped by CacheEntrySchema (or createCacheEntrySchema).
Implements IVersionedCache with revision-fenced atomic coordination,
bypassing the identity map across all read and mutation operations. Reads use
store.em; every write runs in store.transactional(...).
A plain class with no framework dependency.
Example
Section titled “Example”const cache = new MikroOrmCache<UserSnapshot>(store, { defaultTtlMs: 60_000 });Type Parameters
Section titled “Type Parameters”T
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MikroOrmCache<
T>(store,options?):MikroOrmCache<T>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:90
Parameters
Section titled “Parameters”ITransactionalEntityManagerSource
options?
Section titled “options?”Returns
Section titled “Returns”MikroOrmCache<T>
Properties
Section titled “Properties”isVersioned
Section titled “isVersioned”
readonlyisVersioned:true
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:85
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”delete()
Section titled “delete()”delete(
key):Promise<void>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:308
Removes the value and advances the key’s revision, as invalidate() does; the row is kept.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”get(
key):Promise<T|undefined>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:240
Get a value from the cache by key. Handles TTL expiry and returns detached clone.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<T | undefined>
Implementation of
Section titled “Implementation of”invalidate()
Section titled “invalidate()”invalidate(
key):Promise<string>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:134
Atomically advances the revision for key and evicts the payload value.
Retains the entry to prevent ABA races during concurrent fills.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”readState()
Section titled “readState()”readState(
key):Promise<CacheStateEntry<T>>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:102
Observes the current key state and its revision token. Reads bypass the identity map to guarantee authoritative persistence visibility.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”set(
key,value,options?):Promise<void>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:248
Stores a value in the relational cache table with transactional CAS concurrency safety.
Parameters
Section titled “Parameters”string
T
options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”tryFill()
Section titled “tryFill()”tryFill(
key,observedRevision,value,options?):Promise<boolean>
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:179
Atomically checks that current revision matches observedRevision, writes
value, and advances revision on match.
Parameters
Section titled “Parameters”string
observedRevision
Section titled “observedRevision”string
T
options?
Section titled “options?”Returns
Section titled “Returns”Promise<boolean>