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