Use cache for ttl if possible

Also fixes etag when compression enabled
This commit is contained in:
Ajay
2024-04-11 17:54:32 -04:00
parent 7c77bf566e
commit 0602fdd651
3 changed files with 11 additions and 1 deletions

View File

@@ -193,6 +193,15 @@ if (config.redis?.enabled) {
}
};
const ttl = client.ttl.bind(client);
exportClient.ttl = (key) => {
if (cache && cacheClient && cache.has(key)) {
return Promise.resolve(config.redis?.expiryTime - Math.floor((cache.ttl - cache.info(key).ttl) / 1000));
} else {
return ttl(createKeyName(key));
}
};
const get = client.get.bind(client);
const getRead = readClient?.get?.bind(readClient);
exportClient.get = (key) => new Promise((resolve, reject) => {