(context: IContext)
| 534 | }; |
| 535 | |
| 536 | export const toCacheKey = (context: IContext) => { |
| 537 | const { model, handlerType } = context; |
| 538 | const config = model.getCacheConfiguration(handlerType); |
| 539 | const keyData = config?.cacheKey |
| 540 | ? config.cacheKey(context.req) |
| 541 | : defaultCacheKeyFunction(context.req); |
| 542 | const key = crypto.createHash("sha256").update(keyData).digest("hex"); |
| 543 | const prefix = toCachePrefix(config?.cachePrefix); |
| 544 | const modelName = model.name.toLowerCase(); |
| 545 | return `${prefix}:${modelName}:${key}`; |
| 546 | }; |
| 547 | |
| 548 | export const putCache = async (context: IContext, data: any) => { |
| 549 | // Getting the correct configuration |
no test coverage detected