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 2022/10/18 09:11:36 UTC
[GitHub] [apisix] membphis commented on a diff in pull request #8113: fix: add dynamic route cache key
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org