import { TypeList } from "docs-ui" # CachingUtils ## Functions - [Cached](page.mdx#cached) - [useCache](page.mdx#usecache) ## Functions ### Cached This function is used to cache the result of a method call. #### Type Parameters #### Parameters [MedusaContainer](../../medusa/types/medusa.MedusaContainer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string` \\| (`args`: [TargetMethodArgs](../types/utils.TargetMethodArgs/page.mdx)<Target, PropertyKey>, `cachingModule`: [ICachingModuleService](../../types/CachingTypes/interfaces/types.CachingTypes.ICachingModuleService/page.mdx)) => `string` \\| `any`[] \\| Promise<any[]> \\| Promise<string>","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](../types/utils.TargetMethodArgs/page.mdx)<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](../types/utils.TargetMethodArgs/page.mdx)<Target, PropertyKey>) => `undefined` \\| `string`[]","description":"The tags to use for the cache.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"`number` \\| (`args`: [TargetMethodArgs](../types/utils.TargetMethodArgs/page.mdx)<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](../types/utils.TargetMethodArgs/page.mdx)<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](../types/utils.TargetMethodArgs/page.mdx)<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"/> #### Returns 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"/> ##### Parameters ##### Returns ### useCache This function is used to cache the result of a function call. #### Type Parameters #### Parameters 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](../../medusa/types/medusa.MedusaContainer/page.mdx)","description":"The Medusa Container extends [Awilix](https://github.com/jeffijoe/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"/> #### Returns