use redis expire event to delete stored data immediately
This commit is contained in:
parent
490a1e88eb
commit
58840e2c00
@ -14,6 +14,11 @@ const conf = convict({
|
||||
default: 'localhost',
|
||||
env: 'REDIS_HOST'
|
||||
},
|
||||
redis_event_expire: {
|
||||
format: Boolean,
|
||||
default: false,
|
||||
env: 'REDIS_EVENT_EXPIRE'
|
||||
},
|
||||
listen_port: {
|
||||
format: 'port',
|
||||
default: 1443,
|
||||
|
@ -61,6 +61,20 @@ if (config.s3_bucket) {
|
||||
};
|
||||
}
|
||||
|
||||
if (config.redis_event_expire) {
|
||||
const forceDelete = config.s3_bucket ? awsForceDelete : localForceDelete;
|
||||
const redis_sub = redis_client.duplicate();
|
||||
const subKey = '__keyevent@0__:expired';
|
||||
redis_sub.psubscribe(subKey, function() {
|
||||
log.info('Redis:', 'subscribed to expired key events');
|
||||
});
|
||||
|
||||
redis_sub.on('pmessage', function(channel, message, id) {
|
||||
log.info('RedisExpired:', id);
|
||||
forceDelete(id);
|
||||
});
|
||||
}
|
||||
|
||||
function flushall() {
|
||||
redis_client.flushdb();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user