This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push: new ee24e5a3d fix(ai): use # to concat route cache key parts (#8128) ee24e5a3d is described below commit ee24e5a3df8da5a1b5bcb63394ac39253f351af3 Author: jinhua luo <home_k...@163.com> AuthorDate: Thu Oct 20 17:09:56 2022 +0800 fix(ai): use # to concat route cache key parts (#8128) better performance and much clearer --- apisix/plugins/ai.lua | 7 +++---- t/plugin/ai.t | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apisix/plugins/ai.lua b/apisix/plugins/ai.lua index 6b60aac29..cb69f59a7 100644 --- a/apisix/plugins/ai.lua +++ b/apisix/plugins/ai.lua @@ -21,7 +21,6 @@ local event = require("apisix.core.event") local ipairs = ipairs local pcall = pcall local loadstring = loadstring -local encode_base64 = ngx.encode_base64 local get_cache_key_func local get_cache_key_func_def_render @@ -31,10 +30,10 @@ return function(ctx) local var = ctx.var return var.uri {% if route_flags["methods"] then %} - .. "\0" .. var.method + .. "#" .. var.method {% end %} {% if route_flags["host"] then %} - .. "\0" .. var.host + .. "#" .. var.host {% end %} end ]] @@ -68,7 +67,7 @@ end local function ai_match(ctx) local key = get_cache_key_func(ctx) - core.log.info("route cache key: ", core.log.delay_exec(encode_base64, key)) + core.log.info("route cache key: ", key) local ver = router.router_http.user_routes.conf_version local route_cache = route_lrucache(key, ver, match_route, ctx) diff --git a/t/plugin/ai.t b/t/plugin/ai.t index 3c0cd62d9..9415771ab 100644 --- a/t/plugin/ai.t +++ b/t/plugin/ai.t @@ -520,7 +520,7 @@ use ai plane to match route --- response_body done --- error_log -route cache key: L2hlbGxv +route cache key: /hello @@ -569,7 +569,7 @@ route cache key: L2hlbGxv --- response_body done --- error_log -route cache key: L2hlbGxvAEdFVA== +route cache key: /hello#GET @@ -619,4 +619,4 @@ route cache key: L2hlbGxvAEdFVA== --- response_body done --- error_log -route cache key: L2hlbGxvAEdFVAAxMjcuMC4wLjE= +route cache key: /hello#GET#127.0.0.1