MCPcopy Create free account
hub / github.com/axe-api/axe-api / toCacheKey

Function toCacheKey

packages/axe-api/src/Handlers/Helpers.ts:536–546  ·  view source on GitHub ↗
(context: IContext)

Source from the content-addressed store, hash-verified

534};
535
536export 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
548export const putCache = async (context: IContext, data: any) => {
549 // Getting the correct configuration

Callers 2

GetCachePhase.tsFile · 0.90
putCacheFunction · 0.85

Calls 4

defaultCacheKeyFunctionFunction · 0.85
toCachePrefixFunction · 0.85
updateMethod · 0.80
getCacheConfigurationMethod · 0.65

Tested by

no test coverage detected