Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
exports.register = function (server, options, next) {
server.dependency('vision');
var cache = server.cache({
expiresIn: 30 * 1000,
generateFunc: function (id, next) {
server.render(id.template, id.context, id.options, function(err, rendered){
next(null rendered);
})
}
});
server.decorate('reply', 'viewCache', function (template, context, options) {
var id = JSON.stringify({template: template, context:context, options: options}); // I would recommend to shorten key somehow using some good checksum
return this.response(cache.get({id:id, template: template, context: context, options:options}));
});
return next();
};
exports.register.attributes = {
pkg: require('../package.json')
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment