You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/30 07:24:11 UTC

[GitHub] [apisix] spacewander opened a new pull request #2575: change: make lrucache lock optional

spacewander opened a new pull request #2575:
URL: https://github.com/apache/apisix/pull/2575


   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   
   Close #2520 


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

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



[GitHub] [apisix] moonming merged pull request #2575: change: make lrucache lock optional

Posted by GitBox <gi...@apache.org>.
moonming merged pull request #2575:
URL: https://github.com/apache/apisix/pull/2575


   


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

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



[GitHub] [apisix] membphis commented on a change in pull request #2575: change: make lrucache lock optional

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #2575:
URL: https://github.com/apache/apisix/pull/2575#discussion_r515770469



##########
File path: apisix/core/lrucache.lua
##########
@@ -125,42 +139,37 @@ end
 global_lru_fun = new_lru_fun()
 
 
-local function _plugin(plugin_name, key, version, create_obj_fun, ...)
-    local lru_global = global_lru_fun("/plugin/" .. plugin_name, nil,
-                                      lru_new, PLUGIN_ITEMS_COUNT)
-
-    local obj, stale_obj = lru_global:get(key)
-    if obj and obj.ver == version then
-        return obj.val
-    end
-
-    if stale_obj and stale_obj.ver == version then
-        lru_global:set(key, stale_obj, PLUGIN_TTL)
-        return stale_obj
-    end
+local plugin_ctx
+do
+    local key_buf = {
+        nil,
+        nil,
+        nil,
+    }
+
+    function plugin_ctx(lrucache, api_ctx, extra_key, create_obj_fun, ...)

Review comment:
       `create_obj_fun` -> `create_obj_func`




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

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



[GitHub] [apisix] spacewander commented on a change in pull request #2575: change: make lrucache lock optional

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #2575:
URL: https://github.com/apache/apisix/pull/2575#discussion_r515773064



##########
File path: apisix/core/lrucache.lua
##########
@@ -125,42 +139,37 @@ end
 global_lru_fun = new_lru_fun()
 
 
-local function _plugin(plugin_name, key, version, create_obj_fun, ...)
-    local lru_global = global_lru_fun("/plugin/" .. plugin_name, nil,
-                                      lru_new, PLUGIN_ITEMS_COUNT)
-
-    local obj, stale_obj = lru_global:get(key)
-    if obj and obj.ver == version then
-        return obj.val
-    end
-
-    if stale_obj and stale_obj.ver == version then
-        lru_global:set(key, stale_obj, PLUGIN_TTL)
-        return stale_obj
-    end
+local plugin_ctx
+do
+    local key_buf = {
+        nil,
+        nil,
+        nil,
+    }
+
+    function plugin_ctx(lrucache, api_ctx, extra_key, create_obj_fun, ...)

Review comment:
       Updated.




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

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



[GitHub] [apisix] spacewander commented on a change in pull request #2575: change: make lrucache lock optional

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #2575:
URL: https://github.com/apache/apisix/pull/2575#discussion_r521784444



##########
File path: apisix/core/lrucache.lua
##########
@@ -125,42 +139,37 @@ end
 global_lru_fun = new_lru_fun()
 
 
-local function _plugin(plugin_name, key, version, create_obj_fun, ...)
-    local lru_global = global_lru_fun("/plugin/" .. plugin_name, nil,
-                                      lru_new, PLUGIN_ITEMS_COUNT)
-
-    local obj, stale_obj = lru_global:get(key)
-    if obj and obj.ver == version then
-        return obj.val
-    end
-
-    if stale_obj and stale_obj.ver == version then
-        lru_global:set(key, stale_obj, PLUGIN_TTL)
-        return stale_obj

Review comment:
       Here we need to return `stale_obj.val` instead. Otherwise, the returned value will be:
   ```
   ver = xxx,
   val = actual_cache_obj,
   ```




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

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