Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Can't kill Redis connection from Node JS using ioredis

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda