Add in process-caching, example links
This commit is contained in:
parent
a401a0a351
commit
69c60a078e
4 changed files with 19 additions and 4 deletions
|
@ -4,10 +4,13 @@ var Q = require('q');
|
|||
|
||||
var services = {};
|
||||
|
||||
var cache = {};
|
||||
|
||||
require("fs").readdirSync(path.join(__dirname, "..", "lib", "services")).forEach(function(file) {
|
||||
var service = require("../lib/services/" + file);
|
||||
if (service.search) {
|
||||
services[service.id] = service;
|
||||
cache[service.id] = {};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -17,6 +20,11 @@ module.exports = function(req, res) {
|
|||
var itemId = req.params.id;
|
||||
var promises = [];
|
||||
|
||||
if (cache[serviceId][type + "-" + itemId]) {
|
||||
res.render(type, {items: cache[serviceId][type + "-" + itemId]});
|
||||
return;
|
||||
}
|
||||
|
||||
services[serviceId].lookupId(itemId, type).then(function(item) {
|
||||
for (var id in services) {
|
||||
if (id != serviceId) {
|
||||
|
@ -38,7 +46,7 @@ module.exports = function(req, res) {
|
|||
});
|
||||
|
||||
items.unshift(item);
|
||||
|
||||
cache[serviceId][item.type + "-" + item.id] = items;
|
||||
res.render(type, {items: items});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue