Add caching for Moleculer service methods too. This mixin creates a memoize
method which caches responses in service methods.
const Memoize = require("../mixins/memoize.mixin");
module.exports = {
name: "acl",
mixins: [
Memoize()
],
methods: {
async getPermissions(roleNames) {
return await this.memoize("permissions", roleNames, async () => {
// Do something. The response will be cached based on `roleNames` value.
return res;
});
},
}
}