|
|
|
@ -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'); |
|
|
|
|