spacewander commented on code in PR #8578:
URL: https://github.com/apache/apisix/pull/8578#discussion_r1060308412


##########
apisix/plugins/limit-count/limit-count-local.lua:
##########
@@ -0,0 +1,64 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local limit_local_new = require("resty.limit.count").new
+local ngx = ngx
+local ngx_time = ngx.time
+local assert = assert
+local setmetatable = setmetatable
+
+local _M = {}
+
+local mt = {
+    __index = _M
+}
+
+function _M.set_endtime(self,key,time_window)

Review Comment:
   Look like we can merge `set_endtime` into the `incoming` method, especially 
after implementing `read_reset` via eval?



##########
apisix/plugins/limit-count/limit-count-redis-cluster.lua:
##########
@@ -84,6 +84,23 @@ function _M.new(plugin_name, limit, window, conf)
     return setmetatable(self, mt)
 end
 
+function _M.set_endtime(self,key,time_window)
+    return time_window
+end
+
+function _M.read_reset(self, key)
+    local red = self.red_cli
+    key = self.plugin_name .. tostring(key)
+    local ttl, err = red:ttl(key)

Review Comment:
   Can we put this into the eval script to make it atomic and reduce roundtrip?



##########
apisix/cli/ngx_tpl.lua:
##########
@@ -276,6 +276,7 @@ http {
     {% if enabled_plugins["limit-count"] then %}
     lua_shared_dict plugin-limit-count {* 
http.lua_shared_dict["plugin-limit-count"] *};
     lua_shared_dict plugin-limit-count-redis-cluster-slot-lock {* 
http.lua_shared_dict["plugin-limit-count-redis-cluster-slot-lock"] *};
+    lua_shared_dict plugin-limit-count-reset-header {* 
http.lua_shared_dict["plugin-limit-count-reset-header"] *};

Review Comment:
   Maybe we can let the size of plugin-limit-count-reset-header be equal to 
plugin-limit-count, so that people don't need to configure it twice? As these 
two shdict store similar data.



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to