MikroOrmCache
Defined in: packages/mikro-orm/src/cache/mikro-orm.cache.ts:129
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”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:135
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:130
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:243
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:210
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:179
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:147
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:218
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:187
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>