Ukladaj pomalé výsledky na disk cez FILECACHE
FILECACHE(id, expiration, callback, maker) hľadá cache súbor pre id. Ak existuje a je mladší ako expiration (text ako '1 minute'), callback dostane jeho obsah; inak zavolá maker(done), aby hodnotu vypočítal, uloží ju a vráti. Výsledok sa serializuje ako JSON. Na rozdiel od CACHE prežije reštart a hodí sa aj pre veľké výsledky.
exports.install = function() {
ROUTE('GET /report/', report);
};
var computed = 0;
function report($) {
FILECACHE('monthly-report', '1 minute', function(err, response) {
$.json({ report: response, computed: computed });
}, function(done) {
// The expensive work goes here
computed++;
done(null, { total: 42, generated: computed });
});
}