Skip to content

Commit 3bdad63

Browse files
committed
remove unnecessary math.floor function
1 parent 6499875 commit 3bdad63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/resty/limit/req.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if res then
2828
end
2929
3030
local ms = math.abs(now - last)
31-
excess = excess - math.floor(rate * ms / 1000) + 1000
31+
excess = excess - rate * ms / 1000 + 1000
3232
3333
if excess < 0 then
3434
excess = 0
@@ -80,7 +80,7 @@ local function redis_lookup(conn, zone, key, rate, duration)
8080
redis_limit_req_script_sha = res
8181
end
8282

83-
local now = math.floor(ngx.now() * 1000)
83+
local now = ngx.now() * 1000
8484
local res, err = red:evalsha(redis_limit_req_script_sha, 4,
8585
zone .. ":" .. key, rate, now, duration)
8686
if not res then

0 commit comments

Comments
 (0)