Skip to content

Instantly share code, notes, and snippets.

@rodrigodiez
Last active December 20, 2015 15:39
Show Gist options
  • Select an option

  • Save rodrigodiez/6156330 to your computer and use it in GitHub Desktop.

Select an option

Save rodrigodiez/6156330 to your computer and use it in GitHub Desktop.
Redis flood control
// Primer intento 10:00 AM
> SETEX users:1:comments:attempts:27664A7l 300 fooValue
// Segundo intento 10:01 AM
> SETEX users:1:comments:attempts:lh70Qnvh 300 fooValue
// Tercer intento 10:02 AM
> SETEX users:1:comments:attempts:f2F5mNjl 300 fooValue
// 10:03 AM. Tenemos tres claves diferentes
> KEYS users:1:comments:attempts:*
1) "users:1:comments:attempts:27664A7l"
2) "users:1:comments:attempts:lh70Qnvh"
3) "users:1:comments:attempts:f2F5mNjl"
// 10:05 AM La primera de ellas ha caducado
> KEYS users:1:comments:attempts:*
1) "users:1:comments:attempts:lh70Qnvh"
2) "users:1:comments:attempts:f2F5mNjl"
// 10:07 Todas han caducado
> KEYS users:1:comments:attempts:*
(empty list or set)
@adrien-aubel
Copy link
Copy Markdown

Not sure you should use KEYS in large productions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment