I'm using ioredis package and want to kill connections with idle time > 30 seconds. I use this code:
const clientList = await redisClient.client('list');
if (typeof clientList === 'string') {
await Promise.all(
clientList
.split('\n')
.filter(item => item !== '')
.filter(
item => parseInt(item.match(/.*?idle=(.*)? flags=/)[1], 10) > 30
) // idle > 30 seconds
.map(async item => {
const id = item.match(/.*?id=(.*)? addr=/)[1];
const res = await redisClient.client('kill', 'id', id);
console.log('res', res);
})
);
}
And I get this in console:
res 1
res 1
res 1
...
res 1
res 1
But the connections are not killed.
I've tried to debug it, but everything seems to be ok, except it's just doesn't work as expected.
Also I've tried to manage it via Redis config in redis-cli:
CONFIG SET TIMEOUT 30
This way I see that the number of connections stay the same, but their idle values are resetting (like they reconnect just after server kill them).
Help with it please. Thanks in advance.