|
1
|
{"slug":"/references/utils/utils.CachingUtils","title":"CachingUtils","frontmatter":{},"toc":[{"title":"Functions","id":"functions","level":2},{"title":"Functions","id":"functions-1","level":2},{"title":"Cached","id":"cached","level":3},{"title":"Type Parameters","id":"cached-type-parameters","level":4},{"title":"Parameters","id":"cached-parameters","level":4},{"title":"Returns","id":"cached-returns","level":4},{"title":"useCache","id":"usecache","level":3},{"title":"Type Parameters","id":"usecache-type-parameters","level":4},{"title":"Parameters","id":"usecache-parameters","level":4},{"title":"Returns","id":"usecache-returns","level":4}],"blocks":[{"kind":"heading","level":2,"text":"Functions","id":"functions"},{"kind":"linkList","items":[{"title":"Cached","href":"/references/utils/utils.CachingUtils#cached"},{"title":"useCache","href":"/references/utils/utils.CachingUtils#usecache"}]},{"kind":"heading","level":2,"text":"Functions","id":"functions-1"},{"kind":"heading","level":3,"text":"Cached","id":"cached"},{"kind":"markdown","html":"This function is used to cache the result of a method call."},{"kind":"heading","level":4,"text":"Type Parameters","id":"cached-type-parameters"},{"kind":"typeList","sectionTitle":"Cached","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":[]}]},{"kind":"heading","level":4,"text":"Parameters","id":"cached-parameters"},{"kind":"typeList","sectionTitle":"Cached","types":[{"name":"options","type":"`object`","description":"The options for the cache.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"key","type":"`string` \\| (`args`: [TargetMethodArgs](/references/utils/types/utils.TargetMethodArgs)<Target, PropertyKey>, `cachingModule`: [ICachingModuleService](/references/types/CachingTypes/interfaces/types.CachingTypes.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](/references/utils/types/utils.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](/references/utils/types/utils.TargetMethodArgs)<Target, PropertyKey>) => `undefined` \\| `string`[]","description":"The tags to use for the cache.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"computeAutomaticTags","type":"`boolean` \\| (`args`: [TargetMethodArgs](/references/utils/types/utils.TargetMethodArgs)<Target, PropertyKey>) => `undefined` \\| `boolean`","description":"Whether the automatically computed tags should be applied along with the ones given\nin `tags`, rather than `tags` being used on its own. No effect when `tags` is\nomitted.\n\nThe function form exists so the option can be resolved from the decorated method's\narguments, the same way `tags` is.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"`number` \\| (`args`: [TargetMethodArgs](/references/utils/types/utils.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](/references/utils/types/utils.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](/references/utils/types/utils.TargetMethodArgs)<Target, PropertyKey>) => `undefined` \\| `string`[]","description":"The providers to use for the cache.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"container","type":"[MedusaContainer](/references/medusa/types/medusa.MedusaContainer) \\| (`this`: Target) => [MedusaContainer](/references/medusa/types/medusa.MedusaContainer)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"cached-returns"},{"kind":"typeList","sectionTitle":"Cached","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":[]}]},{"kind":"heading","level":3,"text":"useCache","id":"usecache"},{"kind":"markdown","html":"This function is used to cache the result of a function call."},{"kind":"heading","level":4,"text":"Type Parameters","id":"usecache-type-parameters"},{"kind":"typeList","sectionTitle":"useCache","types":[{"name":"T","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"kind":"heading","level":4,"text":"Parameters","id":"usecache-parameters"},{"kind":"typeList","sectionTitle":"useCache","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":"enable","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string` \\| `any`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"computeAutomaticTags","type":"`boolean`","description":"Whether the automatically computed tags should be applied along with the ones\ngiven in `tags`, rather than `tags` being used on its own. No effect when `tags`\nis omitted.","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":[]},{"name":"container","type":"[MedusaContainer](/references/medusa/types/medusa.MedusaContainer)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"usecache-returns"},{"kind":"typeList","sectionTitle":"useCache","types":[{"name":"Promise","type":"Promise<T>","optional":false,"defaultValue":"","description":"The result of the callback.","expandable":false,"children":[]}]}]} |