diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:34:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:34:44 +0000 |
commit | 02a04a2335701bfc8d6a1087338f58e9f37ceb52 (patch) | |
tree | 92c2c729cfdaaa3942a251357ff100e28a8b8624 /iredis/data/commands/incr.md | |
parent | Adding upstream version 1.9.1. (diff) | |
download | iredis-02a04a2335701bfc8d6a1087338f58e9f37ceb52.tar.xz iredis-02a04a2335701bfc8d6a1087338f58e9f37ceb52.zip |
Adding upstream version 1.9.4.upstream/1.9.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iredis/data/commands/incr.md')
-rw-r--r-- | iredis/data/commands/incr.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/iredis/data/commands/incr.md b/iredis/data/commands/incr.md index 8d8b012..110510e 100644 --- a/iredis/data/commands/incr.md +++ b/iredis/data/commands/incr.md @@ -65,14 +65,14 @@ The more simple and direct implementation of this pattern is the following: FUNCTION LIMIT_API_CALL(ip) ts = CURRENT_UNIX_TIME() keyname = ip+":"+ts -current = GET(keyname) -IF current != NULL AND current > 10 THEN +MULTI + INCR(keyname) + EXPIRE(keyname,10) +EXEC +current = RESPONSE_OF_INCR_WITHIN_MULTI +IF current > 10 THEN ERROR "too many requests per second" ELSE - MULTI - INCR(keyname,1) - EXPIRE(keyname,10) - EXEC PERFORM_API_CALL() END ``` @@ -119,7 +119,7 @@ script that is send using the `EVAL` command (only available since Redis version ``` local current current = redis.call("incr",KEYS[1]) -if tonumber(current) == 1 then +if current == 1 then redis.call("expire",KEYS[1],1) end ``` |