nic-6443 commented on code in PR #11840:
URL: https://github.com/apache/apisix/pull/11840#discussion_r2193898420


##########
apisix/consumer.lua:
##########
@@ -101,46 +152,21 @@ local function plugin_consumer()
                 if not plugins[name] then
                     plugins[name] = {
                         nodes = {},
+                        len = 0,
                         conf_version = consumers.conf_version
                     }
                 end
 
-                -- if the val is a Consumer, clone it to the local consumer;
-                -- if the val is a Credential, to get the Consumer by 
consumer_name and then clone
-                -- it to the local consumer.
-                local consumer
-                if is_credential_etcd_key(val.key) then
-                    local consumer_name = 
get_consumer_name_from_credential_etcd_key(val.key)
-                    local the_consumer = consumers:get(consumer_name)
-                    if the_consumer and the_consumer.value then
-                        consumer = core.table.clone(the_consumer.value)
-                        consumer.modifiedIndex = the_consumer.modifiedIndex
-                        consumer.credential_id = 
get_credential_id_from_etcd_key(val.key)
-                    else
-                        -- Normally wouldn't get here:
-                        -- it should belong to a consumer for any credential.
-                        core.log.error("failed to get the consumer for the 
credential,",
-                            " a wild credential has appeared!",
-                            " credential key: ", val.key, ", consumer name: ", 
consumer_name)
-                        goto CONTINUE
-                    end
-                else
-                    consumer = core.table.clone(val.value)
-                    consumer.modifiedIndex = val.modifiedIndex
-                end
-
-                -- if the consumer has labels, set the field custom_id to it.
-                -- the custom_id is used to set in the request headers to the 
upstream.
-                if consumer.labels then
-                    consumer.custom_id = consumer.labels["custom_id"]
+                local consumer = consumers_id_lrucache(val.value.id .. name,
+                        val.modifiedIndex, construct_consumer_data, val, 
config)

Review Comment:
   We cannot cache the result of `construct_consumer_data` here, because even 
when there is no change in credential (`val.modifiedIndex` has not changed), 
the consumer might have been modified. We need to design different versions for 
`consumer` and `credential`.



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