AlinsRan commented on code in PR #12751:
URL: https://github.com/apache/apisix/pull/12751#discussion_r2583701646
##########
apisix/plugins/limit-count/limit-count-redis.lua:
##########
@@ -52,37 +44,66 @@ function _M.new(plugin_name, limit, window, conf)
return setmetatable(self, mt)
end
-function _M.incoming(self, key, cost)
+
+local function log_phase_incoming_thread(premature, self, key, cost)
local conf = self.conf
local red, err = redis.new(conf)
if not red then
- return red, err, 0
+ return red, err
end
+ return util.redis_log_phase_incoming(self, red, key, cost)
+end
- local limit = self.limit
- local window = self.window
- local res
- key = self.plugin_name .. tostring(key)
- local ttl = 0
- res, err = red:eval(script, 1, key, limit, window, cost or 1)
+local function log_phase_incoming(self, key, cost, dry_run)
+ if dry_run then
+ return true
+ end
- if err then
- return nil, err, ttl
+ local ok, err = ngx_timer_at(0, log_phase_incoming_thread, self, key, cost)
+ if not ok then
+ core.log.error("failed to create timer: ", err)
+ return nil, err
end
- local remaining = res[1]
- ttl = res[2]
+ return ok
+end
+
+
+function _M.incoming(self, key, cost, dry_run)
Review Comment:
Suggest using the `commit` parameter instead of `dry_run`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]