Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
What is the purpose of renaming this key in a redis sliding window rate limiter implementation?

I'm looking at the source for the redis-rate-limiter library here on line 11.

Going through the exec, using "10/minute" rate/duration:

  • Create temp key prefixed with ratelimittemp:ID to 0 and set to expire in 60 seconds
  • Rename to ratelimit:ID
  • Increment ratelimit:ID
  • Get TTL

What's the point of a rename here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's a way to refresh the rate limiter counter. It renames the temp key to real key if the real key does not exist, i.e. renamenx.

If the real key exists, increase the current counter, and see if we reach the rate limit of current time window. However, if the real key does not exist, it means the the previous time window, e.g. 1 minute, has been passed, and we need to start a new time window, i.e. a new counter. So we rename the temp key (with time window as expiration) to the real key, and increase on this new real key.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda