caching in loopback mixin using operation hooks #7467
Unanswered
Optimus2297
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Model.observe('access', function (context, cb) {
// check the cache
// short-cirtcuit to cb(null, cached) when found
});
Model.observe('loaded', function (context, cb) {
// update the cache
});
i am using these hooks for caching data through a mixin, but the response is still coming from Db and not from cache even if the callback is happening. I have also tried ctx.end(null, res) instead of callback but then i am getting the error as ctx.end is not a function. i want to send the response from the hook if the data is available in the cache object.
Beta Was this translation helpful? Give feedback.
All reactions