You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For now I'm using this hook which appears to do the job.
/**
* Caches a service via Redis
* Also ensures that certain params are included in the query to be parsed into the cache key
*
* @returns {function(): *[]}
*/
export default function cacheBefore() {
return iff(
context => context.type === 'before' && includes(['get', 'find'], context.method),
// Store params in the query to parse a cache key inside redisBeforeHook
context => ({
...(context || {}),
params: {
...get(context, 'params', {}),
query: {
...get(context, 'params.query', {}),
// Prevent paginated & non-paginated results from using the same key
$paginate: get(context, 'params.paginate', true),
},
},
}),
// Handle the caching via redis
redisBeforeHook({ immediateCacheKey: true }),
// Remove the params which were added to the query
discardQuery('$paginate'),
);
}
The following two finds returns different results but when cached, will return the first cached result.
I think that certain params should be taken into account when generating the cache key.
The text was updated successfully, but these errors were encountered: