Merge pull request #536 from ehuggett/on-redis-expire
use redis expire event to delete stored data immediately
This commit is contained in:
commit
10e80edb1d
@ -14,6 +14,11 @@ const conf = convict({
|
||||
default: 'localhost',
|
||||
env: 'REDIS_HOST'
|
||||
},
|
||||
redis_event_expire: {
|
||||
format: Boolean,
|
||||
default: false,
|
||||
env: 'REDIS_EVENT_EXPIRE'
|
||||
},
|
||||
listen_address: {
|
||||
format: 'ipaddress',
|
||||
default: '0.0.0.0',
|
||||
|
@ -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