[Cache | Trunk]: Change size to memsize while it is setting the cache current entries on metrics.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@59194 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
5afebcd7af
commit
977c465079
|
@ -40,7 +40,7 @@ const histogram = new prom.Histogram({
|
|||
let cache = () => {
|
||||
return (req, res, next) => {
|
||||
if(req.query.url) {
|
||||
if(mcache.size() > cacheMaxSize){
|
||||
if(mcache.memsize() > cacheMaxSize){
|
||||
console.log("Max cache size reached!"+cacheMaxSize);
|
||||
clearCache();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ let cache = () => {
|
|||
res.sendResponse = res.send;
|
||||
res.send = (body) => {
|
||||
let alreadyCached = !!mcache.get(key);
|
||||
entries.set(mcache.size());
|
||||
entries.set(mcache.memsize());
|
||||
if(!alreadyCached) {
|
||||
responses.inc({scheme: scheme, target: target, code: res.statusCode});
|
||||
end();
|
||||
|
@ -68,7 +68,7 @@ let cache = () => {
|
|||
if (res.statusCode === 200) {
|
||||
// console.log("Expire in " +(longCache?expireLong:expireShort) + " " +req.query.url);
|
||||
mcache.put(key, body,longCache?expireLong:expireShort, () => {
|
||||
entries.set(mcache.size());
|
||||
entries.set(mcache.memsize());
|
||||
});
|
||||
}
|
||||
res.sendResponse(body);
|
||||
|
|
Loading…
Reference in New Issue