IK
Size: a a a
IK
MI
IK
IV
IK
ИК
GM
GM
ИК
KV
V
KV
IF
IF
const cache = () => {
return (req, res, next) => {
const key = '__express__' + req.originalUrl || req.url;
const exists = myCache.has(key);
if (exists) {
console.log(`from cache: `, req.originalUrl || req.url);
const cachedBody = myCache.get(key);
res.send(cachedBody);
return;
} else {
res.sendResponse = res.send;
res.send = (body) => {
myCache.set(key, body);
res.sendResponse(body);
};
next();
}
};
};IF
ИК
const cache = () => {
return (req, res, next) => {
const key = '__express__' + req.originalUrl || req.url;
const exists = myCache.has(key);
if (exists) {
console.log(`from cache: `, req.originalUrl || req.url);
const cachedBody = myCache.get(key);
res.send(cachedBody);
return;
} else {
res.sendResponse = res.send;
res.send = (body) => {
myCache.set(key, body);
res.sendResponse(body);
};
next();
}
};
};ИК
const cache = () => {
return (req, res, next) => {
const key = '__express__' + req.originalUrl || req.url;
const exists = myCache.has(key);
if (exists) {
console.log(`from cache: `, req.originalUrl || req.url);
const cachedBody = myCache.get(key);
res.send(cachedBody);
return;
} else {
res.sendResponse = res.send;
res.send = (body) => {
myCache.set(key, body);
res.sendResponse(body);
};
next();
}
};
};IF
ИК
ИК