xuruidong commented on code in PR #11840:
URL: https://github.com/apache/apisix/pull/11840#discussion_r1898417604


##########
apisix/consumer.lua:
##########
@@ -186,24 +204,43 @@ function _M.consumers()
 end
 
 
-local function create_consume_cache(consumers_conf, key_attr)
+local create_consume_cache
+do
+    local consumers_plugin_key_lrucache_tab = {}
+
+local function create_new_consumer(consumer)
+    local new_consumer = core.table.clone(consumer)
+    new_consumer.auth_conf = secret.fetch_secrets(new_consumer.auth_conf, 
false)
+    return new_consumer
+end
+
+
+function create_consume_cache(consumers_conf, key_attr, plugin_name)
     local consumer_names = {}
+    local lru_cache = consumers_plugin_key_lrucache_tab[plugin_name]
+    if lru_cache == nil then
+        lru_cache = core.lrucache.new({
+            ttl = 60 * 60 * 24, count = 20480
+        })
+        consumers_plugin_key_lrucache_tab[plugin_name] = lru_cache
+    end
 
     for _, consumer in ipairs(consumers_conf.nodes) do
         core.log.info("consumer node: ", core.json.delay_encode(consumer))
-        local new_consumer = core.table.clone(consumer)
-        new_consumer.auth_conf = secret.fetch_secrets(new_consumer.auth_conf, 
true,
-                                                        
new_consumer.auth_conf, "")
-        consumer_names[new_consumer.auth_conf[key_attr]] = new_consumer
+        local new_consumer = lru_cache(consumer.auth_conf[key_attr],

Review Comment:
   Yes,I‘ll refactor this code.



-- 
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]

Reply via email to