www/apps/resources/references/utils/utils.CachingUtils/page.mdx
import { TypeList } from "docs-ui"
This function is used to cache the result of a method call.
<TypeList types={[{"name":"Target","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PropertyKey","type":"string \| number \| symbol","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="Cached"/>
<TypeList types={[{"name":"options","type":"object","description":"The options for the cache.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"container","type":"MedusaContainer \| (this: Target) => MedusaContainer","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"string \| (args: TargetMethodArgs<Target, PropertyKey>, cachingModule: ICachingModuleService) => string \| any[] \| Promise<string> \| Promise<any[]>","description":"The key to use for the cache.\nIf a function is provided, it will be called with the arguments as the first argument and the\ncontainer as the second argument.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enable","type":"boolean \| (args: TargetMethodArgs<Target, PropertyKey>) => undefined \| boolean","description":"Whether to enable the cache. This is only useful if you want to enable without providing any\nother options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"string[] \| (args: TargetMethodArgs<Target, PropertyKey>) => undefined \| string[]","description":"The tags to use for the cache.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"number \| (args: TargetMethodArgs<Target, PropertyKey>) => undefined \| number","description":"The time-to-live (TTL) value in seconds.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"autoInvalidate","type":"boolean \| (args: TargetMethodArgs<Target, PropertyKey>) => undefined \| boolean","description":"Whether to auto invalidate the cache whenever it is possible.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"providers","type":"string[] \| (args: TargetMethodArgs<Target, PropertyKey>) => undefined \| string[]","description":"The providers to use for the cache.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="Cached"/>
<TypeList types={[{"name":"(target: Target, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => PropertyDescriptor","type":"(target: Target, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => PropertyDescriptor","optional":false,"defaultValue":"","description":"The original method with the cache applied.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="Cached"/>
<TypeList types={[{"name":"target","type":"Target","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"propertyKey","type":"PropertyKey","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"descriptor","type":"PropertyDescriptor","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
<TypeList types={[{"name":"PropertyDescriptor","type":"PropertyDescriptor","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
This function is used to cache the result of a function call.
<TypeList types={[{"name":"T","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="useCache"/>
<TypeList types={[{"name":"cb","type":"(...args: any[]) => Promise<T>","description":"The callback to execute.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"object","description":"The options for the cache.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"key","type":"string \| any[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"container","type":"MedusaContainer","description":"The Medusa Container extends Awilix to\nprovide dependency injection functionalities.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"enable","type":"boolean","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"string[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"number","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"autoInvalidate","type":"boolean","description":"Whethere the default strategy should auto invalidate the cache whenever it is possible.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"providers","type":"string[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="useCache"/>
<TypeList types={[{"name":"Promise","type":"Promise<T>","optional":false,"defaultValue":"","description":"The result of the callback.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="useCache"/>