Browse Source

fix: refresh TTL on cache set

pull/7596/head
mertmit 9 months ago
parent
commit
4a543bbb1a
  1. 13
      packages/nocodb/src/cache/CacheMgr.ts

13
packages/nocodb/src/cache/CacheMgr.ts vendored

@ -150,12 +150,17 @@ export default abstract class CacheMgr {
});
}
return this.client.set(
return this.client
.set(
key,
JSON.stringify(value, this.getCircularReplacer()),
'EX',
NC_REDIS_TTL,
);
)
.then(async () => {
await this.refreshTTL(key, timestamp);
return true;
});
} else {
log(`${this.context}::set: value is empty for ${key}. Skipping ...`);
return Promise.resolve(true);
@ -534,6 +539,7 @@ export default abstract class CacheMgr {
try {
const o = JSON.parse(v);
if (typeof o === 'object') {
if (o.timestamp !== timestamp) {
o.timestamp = timestamp;
pipeline.set(
key,
@ -542,6 +548,7 @@ export default abstract class CacheMgr {
NC_REDIS_TTL,
);
}
}
} catch (e) {
logger.error(
`${this.context}::refreshTTL: Bad value stored for key ${key} : ${v}`,
@ -560,6 +567,7 @@ export default abstract class CacheMgr {
await this.refreshTTL(parent, timestamp);
}
} else {
if (rawValue.timestamp !== timestamp) {
rawValue.timestamp = timestamp;
await this.client.set(
key,
@ -571,6 +579,7 @@ export default abstract class CacheMgr {
}
}
}
}
async destroy(): Promise<boolean> {
log('${this.context}::destroy: destroy redis');

Loading…
Cancel
Save