diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:34:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:34:57 +0000 |
commit | d71fd6264d58795c50b9350d7c39677b671e0896 (patch) | |
tree | 0aa9e0bd923a00b9ddda4e01af55a76ed314097c /iredis/data/commands/incr.md | |
parent | Releasing debian version 1.9.1-3. (diff) | |
download | iredis-d71fd6264d58795c50b9350d7c39677b671e0896.tar.xz iredis-d71fd6264d58795c50b9350d7c39677b671e0896.zip |
Merging upstream version 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 ``` |