membphis commented on code in PR #8113:
URL: https://github.com/apache/apisix/pull/8113#discussion_r997938380
##########
apisix/core/ai.lua:
##########
@@ -16,8 +16,27 @@
--
local require = require
local core = require("apisix.core")
+local template = require("resty.template")
local ipairs = ipairs
+local get_cache_key_func
+
+local get_cache_key_func_def_render = template.compile([[
+return function(ctx)
+ local key = ctx.var.uri
+
+ {% if route_flags["methods"] then %}
+ key = key .. "\0" .. ctx.var.method
+ {% end %}
+
+ {% if route_flags["host"] then %}
+ key = key .. "\1" .. ctx.var.host
Review Comment:
the second code block is better performance
```lua
local a = "ccc"
a = a .. "bbb"
a = a .. "ccc"
```
```lua
local a = "aaa" .. "bbb" .. "ccc"
```
##########
apisix/core/ai.lua:
##########
@@ -16,8 +16,27 @@
--
local require = require
local core = require("apisix.core")
+local template = require("resty.template")
local ipairs = ipairs
+local get_cache_key_func
+
+local get_cache_key_func_def_render = template.compile([[
+return function(ctx)
+ local key = ctx.var.uri
+
+ {% if route_flags["methods"] then %}
+ key = key .. "\0" .. ctx.var.method
Review Comment:
pls change `"\0"` to a visible characters
--
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]