MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / storeCache

Method storeCache

packages/core/src/EntityManager.ts:3180–3192  ·  view source on GitHub ↗

* @internal

(
    config: boolean | number | [string, number] | undefined,
    key: { key: string },
    data: T | (() => T),
  )

Source from the content-addressed store, hash-verified

3178 * @internal
3179 */
3180 async storeCache<T>(
3181 config: boolean | number | [string, number] | undefined,
3182 key: { key: string },
3183 data: T | (() => T),
3184 ) {
3185 config ??= this.config.get('resultCache').global;
3186
3187 if (config) {
3188 const em = this.getContext();
3189 const expiration = Array.isArray(config) ? config[1] : typeof config === 'number' ? config : undefined;
3190 await em.#resultCache.set(key.key, data instanceof Function ? data() : data, '', expiration);
3191 }
3192 }
3193
3194 /**
3195 * Clears result cache for given cache key. If we want to be able to call this method,

Callers 4

executeMethod · 0.80
findMethod · 0.80
findOneMethod · 0.80
countMethod · 0.80

Calls 3

getContextMethod · 0.95
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected