This is an automated email from the ASF dual-hosted git repository.
liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new ab1d57a591 [feat] cache plugin config based on selector (#6068)
ab1d57a591 is described below
commit ab1d57a5919e89190b224d32e0b60517cf0c6dc9
Author: Yu Siheng <[email protected]>
AuthorDate: Tue Sep 23 09:54:39 2025 +0800
[feat] cache plugin config based on selector (#6068)
* [feat] cache plugin config based on selector
* add:test file
---------
Co-authored-by: aias00 <[email protected]>
Co-authored-by: loongs-zhang <[email protected]>
Co-authored-by: Misaya295 <[email protected]>
---
db/init/mysql/schema.sql | 10 +
db/init/ob/schema.sql | 10 +
db/init/og/create-table.sql | 11 +
db/init/oracle/schema.sql | 30 ++
db/init/pg/create-table.sql | 10 +
db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql | 11 +
db/upgrade/2.7.0-upgrade-2.7.1-ob.sql | 11 +
db/upgrade/2.7.0-upgrade-2.7.1-og.sql | 12 +
db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql | 30 ++
db/upgrade/2.7.0-upgrade-2.7.1-pg.sql | 11 +
.../src/main/resources/sql-script/h2/schema.sql | 10 +
.../common/dto/convert/selector/CacheUpstream.java | 509 +++++++++++++++++++++
.../apache/shenyu/plugin/cache/CachePlugin.java | 39 +-
.../plugin/cache/cache/ApplicationConfigCache.java | 130 ++++++
.../cache/handler/CachePluginDataHandler.java | 9 +
.../plugin/cache/ApplicationConfigCacheTest.java | 93 ++++
.../shenyu/plugin/cache/CachePluginTest.java | 10 +-
17 files changed, 937 insertions(+), 9 deletions(-)
diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql
index 03f36aa718..9ff393acab 100644
--- a/db/init/mysql/schema.sql
+++ b/db/init/mysql/schema.sql
@@ -1177,6 +1177,16 @@ INSERT INTO `plugin_handle` VALUES
('1529402613204172865', '30', 'maxIdle', 'max
INSERT INTO `plugin_handle` VALUES ('1529402613204172866', '30', 'minIdle',
'minIdle', 1, 3, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172867', '30', 'maxActive',
'maxActive', 1, 3, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172868', '30', 'maxWait',
'maxWait', 3, 3, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172859', '30', 'cacheType',
'cacheType', 3, 1, 1,
'{\"required\":\"1\",\"defaultValue\":\"memory\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172860', '30', 'database',
'database', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172861', '30', 'master',
'master', 2, 1, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172862', '30', 'mode',
'mode', 2, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"standalone\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172863', '30', 'url', 'url',
2, 1, 5, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172864', '30', 'password',
'password', 2, 1, 6, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172865', '30', 'maxIdle',
'maxIdle', 1, 1, 7,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172866', '30', 'minIdle',
'minIdle', 1, 1, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172867', '30', 'maxActive',
'maxActive', 1, 1, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172868', '30', 'maxWait',
'maxWait', 3, 1, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172869', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{\"required\":\"0\",\"defaultValue\":\"60\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172870', '13',
'corethreads', 'corethreads', 1, 3, 3,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"placeholder\":\"corethreads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172871', '13', 'threads',
'threads', 1, 3, 4,
'{\"required\":\"0\",\"defaultValue\":\"2147483647\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql
index f63cdc5a79..ecc411c434 100644
--- a/db/init/ob/schema.sql
+++ b/db/init/ob/schema.sql
@@ -1143,6 +1143,16 @@ INSERT INTO `plugin_handle` VALUES
('1529402613204172865', '30', 'maxIdle', 'max
INSERT INTO `plugin_handle` VALUES ('1529402613204172866', '30', 'minIdle',
'minIdle', 1, 3, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172867', '30', 'maxActive',
'maxActive', 1, 3, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172868', '30', 'maxWait',
'maxWait', 3, 3, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172859', '30', 'cacheType',
'cacheType', 3, 1, 1,
'{\"required\":\"1\",\"defaultValue\":\"memory\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172860', '30', 'database',
'database', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172861', '30', 'master',
'master', 2, 1, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172862', '30', 'mode',
'mode', 2, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"standalone\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172863', '30', 'url', 'url',
2, 1, 5, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172864', '30', 'password',
'password', 2, 1, 6, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172865', '30', 'maxIdle',
'maxIdle', 1, 1, 7,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172866', '30', 'minIdle',
'minIdle', 1, 1, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172867', '30', 'maxActive',
'maxActive', 1, 1, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172868', '30', 'maxWait',
'maxWait', 3, 1, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172869', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{\"required\":\"0\",\"defaultValue\":\"60\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172870', '13',
'corethreads', 'corethreads', 1, 3, 3,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"placeholder\":\"corethreads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172871', '13', 'threads',
'threads', 1, 3, 4,
'{\"required\":\"0\",\"defaultValue\":\"2147483647\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql
index 00b07a50fc..23f424dfe0 100644
--- a/db/init/og/create-table.sql
+++ b/db/init/og/create-table.sql
@@ -1183,6 +1183,17 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524909', '30', 'minId
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524910', '30',
'maxActive', 'maxActive', 1, 3, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524911', '30',
'maxWait', 'maxWait', 3, 3, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524912', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{"required":"0","defaultValue":"60","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524902', '30',
'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524903', '30',
'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524904', '30',
'master', 'master', 2, 1, 3, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524905', '30',
'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524906', '30',
'url', 'url', 2, 1, 5, '{"required":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524907', '30',
'password', 'password', 2, 1, 6, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524908', '30',
'maxIdle', 'maxIdle', 1, 1, 7, '{"required":"0","defaultValue":"8","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524909', '30',
'minIdle', 'minIdle', 1, 1, 8, '{"required":"0","defaultValue":"0","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524910', '30',
'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524911', '30',
'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524912', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{"required":"0","defaultValue":"60","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524913', '13',
'corethreads', 'corethreads', 1, 3, 3,
'{"required":"0","defaultValue":"0","placeholder":"corethreads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524914', '13',
'threads', 'threads', 1, 3, 4,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524915', '13',
'queues', 'queues', 1, 3, 5,
'{"required":"0","defaultValue":"0","placeholder":"queues","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index 47533be3eb..62c33b2e26 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -1360,6 +1360,36 @@ values ('1518229897218662407', '30', 'maxActive',
'maxActive', 1, 3, 9, '{"requi
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1518229897218662408', '30', 'maxWait', 'maxWait', 3, 3, 10,
'{"required":"0","defaultValue":"-1","rule":""}');
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897214468163', '30', 'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662400', '30', 'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662401', '30', 'master', 'master', 2, 1, 3,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662402', '30', 'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662403', '30', 'url', 'url', 2, 1, 5,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662404', '30', 'password', 'password', 2, 1, 6,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662405', '30', 'maxIdle', 'maxIdle', 1, 1, 7,
'{"required":"0","defaultValue":"8","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662406', '30', 'minIdle', 'minIdle', 1, 1, 8,
'{"required":"0","defaultValue":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662407', '30', 'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662408', '30', 'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}');
+
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1518229897218662409', '30', 'timeoutSeconds', 'timeoutSeconds', 1, 2,
0, '{"required":"0","defaultValue":"60","rule":""}');
diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql
index a9afbf0f63..488bc7c356 100644
--- a/db/init/pg/create-table.sql
+++ b/db/init/pg/create-table.sql
@@ -1242,6 +1242,16 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524908', '30', 'maxId
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524909', '30',
'minIdle', 'minIdle', 1, 3, 8, '{"required":"0","defaultValue":"0","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524910', '30',
'maxActive', 'maxActive', 1, 3, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524911', '30',
'maxWait', 'maxWait', 3, 3, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524902', '30',
'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524903', '30',
'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524904', '30',
'master', 'master', 2, 1, 3, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524905', '30',
'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524906', '30',
'url', 'url', 2, 1, 5, '{"required":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524907', '30',
'password', 'password', 2, 1, 6, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524908', '30',
'maxIdle', 'maxIdle', 1, 1, 7, '{"required":"0","defaultValue":"8","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524909', '30',
'minIdle', 'minIdle', 1, 1, 8, '{"required":"0","defaultValue":"0","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524910', '30',
'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524911', '30',
'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524912', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{"required":"0","defaultValue":"60","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524913', '13',
'corethreads', 'corethreads', 1, 3, 3,
'{"required":"0","defaultValue":"0","placeholder":"corethreads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524914', '13',
'threads', 'threads', 1, 3, 4,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
index 125bb16dd6..ab48df7b17 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
@@ -170,6 +170,17 @@ INSERT INTO `plugin_handle` VALUES ('1899702411294539776',
'51', 'timeWindowSeco
INSERT INTO `plugin_handle` VALUES ('1899702472330051584', '51', 'keyName',
'keyName', 2, 2, 2, '{\"required\":\"0\",\"rule\":\"\"}', '2025-03-12
06:02:18.707', '2025-03-12 06:02:18.707');
INSERT INTO `plugin_handle` VALUES ('1899702529972371456', '51', 'tokenLimit',
'tokenLimit', 1, 2, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2025-03-12
06:02:32.450', '2025-03-12 06:02:32.450');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172859', '30', 'cacheType',
'cacheType', 3, 1, 1,
'{\"required\":\"1\",\"defaultValue\":\"memory\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172860', '30', 'database',
'database', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172861', '30', 'master',
'master', 2, 1, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172862', '30', 'mode',
'mode', 2, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"standalone\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172863', '30', 'url', 'url',
2, 1, 5, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172864', '30', 'password',
'password', 2, 1, 6, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172865', '30', 'maxIdle',
'maxIdle', 1, 1, 7,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172866', '30', 'minIdle',
'minIdle', 1, 1, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172867', '30', 'maxActive',
'maxActive', 1, 1, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172868', '30', 'maxWait',
'maxWait', 3, 1, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+
INSERT INTO `plugin` VALUES ('53', 'aiRequestTransformer', NULL, 'Ai', 65, 0,
'2023-12-20 18:02:53', '2023-12-20 18:02:53', null);
INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`,
`sort`, `enabled`, `date_created`, `date_updated`) VALUES
('1801816010882822190','649330b6-c2d7-4edc-be8e-8a54df9eb385','53', NULL, 65,
0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
index 157fdea787..5ab479222e 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
@@ -165,6 +165,17 @@ INSERT INTO `plugin_handle` VALUES ('1899702411294539776',
'51', 'timeWindowSeco
INSERT INTO `plugin_handle` VALUES ('1899702472330051584', '51', 'keyName',
'keyName', 2, 2, 2, '{\"required\":\"0\",\"rule\":\"\"}', '2025-03-12
06:02:18.707', '2025-03-12 06:02:18.707');
INSERT INTO `plugin_handle` VALUES ('1899702529972371456', '51', 'tokenLimit',
'tokenLimit', 1, 2, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2025-03-12
06:02:32.450', '2025-03-12 06:02:32.450');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172859', '30', 'cacheType',
'cacheType', 3, 1, 1,
'{\"required\":\"1\",\"defaultValue\":\"memory\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172860', '30', 'database',
'database', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172861', '30', 'master',
'master', 2, 1, 3, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172862', '30', 'mode',
'mode', 2, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"standalone\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172863', '30', 'url', 'url',
2, 1, 5, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172864', '30', 'password',
'password', 2, 1, 6, '{\"required\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172865', '30', 'maxIdle',
'maxIdle', 1, 1, 7,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172866', '30', 'minIdle',
'minIdle', 1, 1, 8,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172867', '30', 'maxActive',
'maxActive', 1, 1, 9,
'{\"required\":\"0\",\"defaultValue\":\"8\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1729402613204172868', '30', 'maxWait',
'maxWait', 3, 1, 10,
'{\"required\":\"0\",\"defaultValue\":\"-1\",\"rule\":\"\"}', '2022-05-25
18:02:53', '2022-05-25 18:02:53');
+
INSERT INTO `plugin` VALUES ('53', 'aiRequestTransformer', NULL, 'Ai', 65, 0,
'2023-12-20 18:02:53', '2023-12-20 18:02:53', null);
INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`,
`sort`, `enabled`, `date_created`, `date_updated`) VALUES
('1801816010882822190','649330b6-c2d7-4edc-be8e-8a54df9eb385','53', NULL, 65,
0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
index 2d2b7fff7a..3d2baafa38 100644
--- a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
@@ -179,6 +179,18 @@ INSERT INTO "public"."plugin_handle" VALUES
('1899702411294539776', '51', 'timeW
INSERT INTO "public"."plugin_handle" VALUES ('1899702472330051584', '51',
'keyName', 'keyName', 2, 2, 2, '{"required":"0","rule":""}', '2025-03-12
06:02:18.707', '2025-03-12 06:02:18.707');
INSERT INTO "public"."plugin_handle" VALUES ('1899702529972371456', '51',
'tokenLimit', 'tokenLimit', 1, 2, 3, '{"required":"0","rule":""}', '2025-03-12
06:02:32.450', '2025-03-12 06:02:32.450');
+INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524902', '30',
'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524903', '30',
'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524904', '30',
'master', 'master', 2, 1, 3, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524905', '30',
'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524906', '30',
'url', 'url', 2, 1, 5, '{"required":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524907', '30',
'password', 'password', 2, 1, 6, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524908', '30',
'maxIdle', 'maxIdle', 1, 1, 7, '{"required":"0","defaultValue":"8","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524909', '30',
'minIdle', 'minIdle', 1, 1, 8, '{"required":"0","defaultValue":"0","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524910', '30',
'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524911', '30',
'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524912', '30',
'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{"required":"0","defaultValue":"60","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+
INSERT INTO "public"."plugin" VALUES ('53', 'aiRequestTransformer', NULL,
'Ai', 65, 0, '2023-12-20 18:02:53', '2023-12-20 18:02:53', null);
INSERT INTO "public"."namespace_plugin_rel" VALUES
('1801816010882822190','649330b6-c2d7-4edc-be8e-8a54df9eb385','53', NULL, 65,
0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
index d1c796bf9d..f6042eacd9 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
@@ -386,6 +386,36 @@ VALUES ('1899702529972371456', '51', 'tokenLimit',
'tokenLimit', 1, 2, 3, '{"req
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
VALUES ('1529402613204173926', '6', 'registry', 'registry', 2, 1, 0,
'{"required":"0","placeholder":"","rule":""}');
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897214468163', '30', 'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662400', '30', 'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662401', '30', 'master', 'master', 2, 1, 3,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662402', '30', 'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662403', '30', 'url', 'url', 2, 1, 5,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662404', '30', 'password', 'password', 2, 1, 6,
'{"required":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662405', '30', 'maxIdle', 'maxIdle', 1, 1, 7,
'{"required":"0","defaultValue":"8","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662406', '30', 'minIdle', 'minIdle', 1, 1, 8,
'{"required":"0","defaultValue":"0","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662407', '30', 'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1718229897218662408', '30', 'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}');
+
UPDATE plugin_handle SET ext_obj = '{"required":"0","rule":""}' WHERE
plugin_id = '6' AND label = 'ip:port' AND data_type = 2;
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('53', 'aiRequestTransformer', NULL, 'Ai',
65, 0);
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
index 4e2d1f6ea2..566d4ae4b0 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
@@ -179,6 +179,17 @@ INSERT INTO "public"."plugin_handle" VALUES
('1899702529972371456', '51', 'token
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204173925', '6',
'registry', 'registry', 2, 1, 0, '{"required":"0","rule":""}', '2025-02-27
17:20:50.233', '2025-02-27 17:20:50.233');
UPDATE "public"."plugin_handle" SET ext_obj = '{"required":"0","rule":""}'
WHERE plugin_id = '6' AND label = 'ip:port' AND data_type = 2;
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524902', '30',
'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524903', '30',
'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524904', '30',
'master', 'master', 2, 1, 3, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524905', '30',
'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524906', '30',
'url', 'url', 2, 1, 5, '{"required":"0","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524907', '30',
'password', 'password', 2, 1, 6, '{"required":"0","rule":""}', '2022-05-25
18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524908', '30',
'maxIdle', 'maxIdle', 1, 1, 7, '{"required":"0","defaultValue":"8","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524909', '30',
'minIdle', 'minIdle', 1, 1, 8, '{"required":"0","defaultValue":"0","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524910', '30',
'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1729403902783524911', '30',
'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+
INSERT INTO "public"."plugin" VALUES ('53', 'aiRequestTransformer', NULL,
'Ai', 65, 0, '2023-12-20 18:02:53', '2023-12-20 18:02:53', null);
INSERT INTO "public"."namespace_plugin_rel" VALUES
('1801816010882822190','649330b6-c2d7-4edc-be8e-8a54df9eb385','53', NULL, 65,
0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
index 7e6ddaf5fb..6588c8af67 100644
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -752,6 +752,16 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172864', '30', 'minIdle', 'minIdle', 1, 3, 8,
'{"required":"0","defaultValue":"0","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172865', '30', 'maxActive', 'maxActive', 1, 3, 9,
'{"required":"0","defaultValue":"8","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172866', '30', 'maxWait', 'maxWait', 3, 3, 10,
'{"required":"0","defaultValue":"-1","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172857', '30', 'cacheType', 'cacheType', 3, 1, 1,
'{"required":"1","defaultValue":"memory","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172858', '30', 'database', 'database', 1, 1, 2,
'{"required":"0","defaultValue":"0","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172859', '30', 'master', 'master', 2, 1, 3,
'{"required":"0","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172860', '30', 'mode', 'mode', 2, 1, 4,
'{"required":"0","defaultValue":"standalone","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172861', '30', 'url', 'url', 2, 1, 5,
'{"required":"0","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172862', '30', 'password', 'password', 2, 1, 6,
'{"required":"0","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172863', '30', 'maxIdle', 'maxIdle', 1, 1, 7,
'{"required":"0","defaultValue":"8","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172864', '30', 'minIdle', 'minIdle', 1, 1, 8,
'{"required":"0","defaultValue":"0","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172865', '30', 'maxActive', 'maxActive', 1, 1, 9,
'{"required":"0","defaultValue":"8","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1729402613204172866', '30', 'maxWait', 'maxWait', 3, 1, 10,
'{"required":"0","defaultValue":"-1","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172867', '30', 'timeoutSeconds', 'timeoutSeconds', 1, 2, 0,
'{"required":"0","defaultValue":"60","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172868', '13', 'corethreads', 'corethreads', 1, 3, 3,
'{"required":"0","defaultValue":"0","placeholder":"corethreads","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172869', '13', 'threads', 'threads', 1, 3, 4,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}');
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CacheUpstream.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CacheUpstream.java
new file mode 100644
index 0000000000..c97d3b1567
--- /dev/null
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CacheUpstream.java
@@ -0,0 +1,509 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.common.dto.convert.selector;
+
+import java.util.Objects;
+
+/**
+ * The type Cache selector upstream.
+ */
+public class CacheUpstream extends CommonUpstream {
+
+ /**
+ * cacheType.
+ */
+ private String cacheType;
+
+ /**
+ * url.
+ */
+ private String url;
+
+ /**
+ * password.
+ */
+ private String password;
+
+ /**
+ * database.
+ */
+ private String database;
+
+ /**
+ * master.
+ */
+ private String master;
+
+ /**
+ * mode.
+ */
+ private String mode;
+
+ /**
+ * maxIdle.
+ */
+ private int maxIdle;
+
+ /**
+ * minIdle.
+ */
+ private int minIdle;
+
+ /**
+ * maxActive.
+ */
+ private int maxActive;
+
+ /**
+ * maxWait.
+ */
+ private int maxWait;
+
+ /**
+ * builder constructor.
+ *
+ * @param builder builder
+ */
+ public CacheUpstream(final Builder builder) {
+ }
+
+ /**
+ * class builder.
+ *
+ * @return Builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * get cacheType.
+ *
+ * @return cacheType
+ */
+ public String getCacheType() {
+ return cacheType;
+ }
+
+ /**
+ * set cacheType.
+ *
+ * @param cacheType cacheType
+ */
+ public void setCacheType(final String cacheType) {
+ this.cacheType = cacheType;
+ }
+
+ /**
+ * get url.
+ *
+ * @return url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * set url.
+ *
+ * @param url url
+ */
+ public void setUrl(final String url) {
+ this.url = url;
+ }
+
+ /**
+ * get password.
+ *
+ * @return password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * set password.
+ *
+ * @param password password
+ */
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ /**
+ * get database.
+ *
+ * @return database
+ */
+ public String getDatabase() {
+ return database;
+ }
+
+ /**
+ * set database.
+ *
+ * @param database database
+ */
+ public void setDatabase(final String database) {
+ this.database = database;
+ }
+
+ /**
+ * get master.
+ *
+ * @return master
+ */
+ public String getMaster() {
+ return master;
+ }
+
+ /**
+ * set master.
+ *
+ * @param master master
+ */
+ public void setMaster(final String master) {
+ this.master = master;
+ }
+
+ /**
+ * get mode.
+ *
+ * @return mode
+ */
+ public String getMode() {
+ return mode;
+ }
+
+ /**
+ * set mode.
+ *
+ * @param mode mode
+ */
+ public void setMode(final String mode) {
+ this.mode = mode;
+ }
+
+ /**
+ * get maxIdle.
+ *
+ * @return maxIdle
+ */
+ public int getMaxIdle() {
+ return maxIdle;
+ }
+
+ /**
+ * set maxIdle.
+ *
+ * @param maxIdle maxIdle
+ */
+ public void setMaxIdle(final int maxIdle) {
+ this.maxIdle = maxIdle;
+ }
+
+ /**
+ * get minIdle.
+ *
+ * @return minIdle
+ */
+ public int getMinIdle() {
+ return minIdle;
+ }
+
+ /**
+ * set minIdle.
+ *
+ * @param minIdle minIdle
+ */
+ public void setMinIdle(final int minIdle) {
+ this.minIdle = minIdle;
+ }
+
+ /**
+ * get maxActive.
+ *
+ * @return maxActive
+ */
+ public int getMaxActive() {
+ return maxActive;
+ }
+
+ /**
+ * set maxActive.
+ *
+ * @param maxActive maxActive
+ */
+ public void setMaxActive(final int maxActive) {
+ this.maxActive = maxActive;
+ }
+
+ /**
+ * get maxWait.
+ *
+ * @return maxWait
+ */
+ public int getMaxWait() {
+ return maxWait;
+ }
+
+ /**
+ * set maxWait.
+ *
+ * @param maxWait maxWait
+ */
+ public void setMaxWait(final int maxWait) {
+ this.maxWait = maxWait;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof CacheUpstream)) {
+ return false;
+ }
+ CacheUpstream that = (CacheUpstream) o;
+ return Objects.equals(cacheType, that.cacheType)
+ && Objects.equals(url, that.url)
+ && Objects.equals(this.getProtocol(), that.getProtocol())
+ && Objects.equals(this.getUpstreamUrl(), that.getUpstreamUrl())
+ && Objects.equals(this.isGray(), that.isGray())
+ && Objects.equals(database, that.database);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(cacheType, url, this.isGray(), database);
+ }
+
+ @Override
+ public String toString() {
+ return "CacheUpstream{"
+ + "cacheType='" + cacheType
+ + "', url='" + url
+ + "', protocol='" + this.getProtocol()
+ + ", upstreamUrl='" + this.getUpstreamUrl()
+ + "', gray=" + this.isGray()
+ + ", database=" + database
+ + "'}";
+ }
+
+ /**
+ * class builder.
+ */
+ public static final class Builder {
+
+ /**
+ * upstreamHost.
+ */
+ private String upstreamHost;
+
+ /**
+ * protocol.
+ */
+ private String protocol;
+
+ /**
+ * upstreamUrl.
+ */
+ private String upstreamUrl;
+
+ /**
+ * weight.
+ */
+ private int weight;
+
+ /**
+ * status.
+ */
+ private boolean statusSet;
+
+ /**
+ * status.
+ */
+ private boolean statusValue;
+
+ /**
+ * timestamp.
+ */
+ private long timestamp;
+
+ /**
+ * cacheType.
+ */
+ private String cacheType;
+
+ /**
+ * url.
+ */
+ private String url;
+
+ /**
+ * password.
+ */
+ private String password;
+
+ /**
+ * database.
+ */
+ private String database;
+
+ /**
+ * master.
+ */
+ private String master;
+
+ /**
+ * mode.
+ */
+ private String mode;
+
+ /**
+ * maxIdle.
+ */
+ private int maxIdle;
+
+ /**
+ * minIdle.
+ */
+ private int minIdle;
+
+ /**
+ * maxActive.
+ */
+ private int maxActive;
+
+ /**
+ * maxWait.
+ */
+ private int maxWait;
+
+ /**
+ * no args constructor.
+ */
+ public Builder() {
+ }
+
+ public CacheUpstream build() {
+ return new CacheUpstream(this);
+ }
+
+ /**
+ * build upstreamHost.
+ *
+ * @param upstreamHost upstreamHost
+ * @return this
+ */
+ public Builder upstreamHost(final String upstreamHost) {
+ this.upstreamHost = upstreamHost;
+ return this;
+ }
+
+ /**
+ * build protocol.
+ *
+ * @param protocol protocol
+ * @return this
+ */
+ public Builder protocol(final String protocol) {
+ this.protocol = protocol;
+ return this;
+ }
+
+ /**
+ * build upstreamUrl.
+ *
+ * @param upstreamUrl upstreamUrl
+ * @return this
+ */
+ public Builder upstreamUrl(final String upstreamUrl) {
+ this.upstreamUrl = upstreamUrl;
+ return this;
+ }
+
+ /**
+ * build weight.
+ *
+ * @param weight weight
+ * @return this
+ */
+ public Builder weight(final int weight) {
+ this.weight = weight;
+ return this;
+ }
+
+ /**
+ * build status.
+ *
+ * @param status status
+ * @return this
+ */
+ public Builder status(final boolean status) {
+ this.statusValue = status;
+ this.statusSet = true;
+ return this;
+ }
+
+ /**
+ * build timestamp.
+ *
+ * @param timestamp timestamp
+ * @return this
+ */
+ public Builder timestamp(final long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ /**
+ * build cacheType.
+ *
+ * @param cacheType cacheType
+ * @return this
+ */
+ public Builder cacheType(final String cacheType) {
+ this.cacheType = cacheType;
+ return this;
+ }
+
+ /**
+ * build url.
+ *
+ * @param url url
+ * @return this
+ */
+ public Builder url(final String url) {
+ this.url = url;
+ return this;
+ }
+
+ /**
+ * build database.
+ *
+ * @param database database
+ * @return this
+ */
+ public Builder database(final String database) {
+ this.database = database;
+ return this;
+ }
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/CachePlugin.java
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/CachePlugin.java
index fefc0d7968..2bb5378ddb 100644
---
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/CachePlugin.java
+++
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/CachePlugin.java
@@ -17,14 +17,18 @@
package org.apache.shenyu.plugin.cache;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.dto.RuleData;
import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.rule.impl.CacheRuleHandle;
+import org.apache.shenyu.common.dto.convert.selector.CacheUpstream;
import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.plugin.api.ShenyuPluginChain;
import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
+import org.apache.shenyu.plugin.cache.cache.ApplicationConfigCache;
import org.apache.shenyu.plugin.cache.handler.CachePluginDataHandler;
import org.apache.shenyu.plugin.cache.utils.CacheUtils;
import org.reactivestreams.Publisher;
@@ -48,7 +52,8 @@ public class CachePlugin extends AbstractShenyuPlugin {
@Override
public Mono<Void> doExecute(final ServerWebExchange exchange, final
ShenyuPluginChain chain,
final SelectorData selector, final RuleData
rule) {
- ICache cache = CacheUtils.getCache();
+ CacheUpstream cacheUpstream =
GsonUtils.getInstance().fromJson(selector.getHandle(), CacheUpstream.class);
+ ICache cache = getCache(selector.getId(), cacheUpstream);
if (Objects.nonNull(cache)) {
return cache.getData(CacheUtils.dataKey(exchange))
.zipWith(cache.getData(CacheUtils.contentTypeKey(exchange)))
@@ -63,11 +68,29 @@ public class CachePlugin extends AbstractShenyuPlugin {
.doOnNext(data ->
exchange.getResponse().getHeaders().setContentLength(data.readableByteCount())));
}
CacheRuleHandle cacheRuleHandle =
buildRuleHandle(rule);
- return chain.execute(exchange.mutate().response(new
CacheHttpResponse(exchange, cacheRuleHandle)).build());
+ return chain.execute(exchange.mutate().response(new
CacheHttpResponse(exchange, cacheRuleHandle, selector.getId())).build());
});
}
CacheRuleHandle cacheRuleHandle = buildRuleHandle(rule);
- return chain.execute(exchange.mutate().response(new
CacheHttpResponse(exchange, cacheRuleHandle)).build());
+ return chain.execute(exchange.mutate().response(new
CacheHttpResponse(exchange, cacheRuleHandle, selector.getId())).build());
+ }
+
+ /**
+ * get and init ICache.
+ *
+ * @param selectorId selectorId
+ * @param cacheUpstream cacheUpstream
+ * @return ICache
+ */
+ private ICache getCache(final String selectorId, final CacheUpstream
cacheUpstream) {
+ if (Objects.isNull(cacheUpstream) ||
StringUtils.isBlank(cacheUpstream.getUrl())) {
+ return CacheUtils.getCache();
+ }
+ ICache cache = ApplicationConfigCache.getInstance().get(selectorId);
+ if (Objects.isNull(cache)) {
+ cache = ApplicationConfigCache.getInstance().init(selectorId,
cacheUpstream);
+ }
+ return cache;
}
@Override
@@ -86,15 +109,19 @@ public class CachePlugin extends AbstractShenyuPlugin {
static class CacheHttpResponse extends ServerHttpResponseDecorator {
+ private final String selectorId;
+
private final ServerWebExchange exchange;
private final CacheRuleHandle cacheRuleHandle;
CacheHttpResponse(final ServerWebExchange exchange,
- final CacheRuleHandle cacheRuleHandle) {
+ final CacheRuleHandle cacheRuleHandle,
+ final String selectorId) {
super(exchange.getResponse());
this.exchange = exchange;
this.cacheRuleHandle = cacheRuleHandle;
+ this.selectorId = selectorId;
}
@Override
@@ -110,7 +137,9 @@ public class CachePlugin extends AbstractShenyuPlugin {
@NonNull
private byte[] cacheResponse(final byte[] bodyBytes) {
- final ICache cache = CacheUtils.getCache();
+ ICache cache;
+ ICache selectorCache =
ApplicationConfigCache.getInstance().get(selectorId);
+ cache = Objects.isNull(selectorCache) ? CacheUtils.getCache() :
selectorCache;
if (Objects.nonNull(cache)) {
final MediaType contentType =
this.getHeaders().getContentType();
cache.cacheData(CacheUtils.dataKey(this.exchange), bodyBytes,
diff --git
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/cache/ApplicationConfigCache.java
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/cache/ApplicationConfigCache.java
new file mode 100644
index 0000000000..0b18e14a0b
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/cache/ApplicationConfigCache.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.cache.cache;
+
+import com.google.common.collect.Maps;
+import org.apache.shenyu.common.dto.convert.selector.CacheUpstream;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.plugin.cache.ICache;
+import org.apache.shenyu.plugin.cache.ICacheBuilder;
+import org.apache.shenyu.spi.ExtensionLoader;
+
+
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.shenyu.plugin.api.ShenyuPlugin.LOG;
+
+/**
+ * ApplicationConfigCache.
+ */
+public class ApplicationConfigCache {
+
+ private static final Map<String, CacheUpstream> UPSTREAM_CACHE_MAP =
Maps.newConcurrentMap();
+
+ private static final Map<String, ICache> CONFIG_CACHE_MAP =
Maps.newConcurrentMap();
+
+ public ICache init(final String selectorId, final CacheUpstream
cacheUpstream) {
+ String config = GsonUtils.getInstance().toJson(cacheUpstream);
+ final ICacheBuilder cacheBuilder =
ExtensionLoader.getExtensionLoader(ICacheBuilder.class)
+ .getJoin(cacheUpstream.getCacheType());
+ ICache cache = cacheBuilder.builderCache(config);
+ CONFIG_CACHE_MAP.put(selectorId, cache);
+ UPSTREAM_CACHE_MAP.put(selectorId, cacheUpstream);
+ return cache;
+ }
+
+ /**
+ * Get ICache .
+ *
+ * @param path the path
+ * @return the ICache
+ */
+ public ICache get(final String path) {
+ return CONFIG_CACHE_MAP.get(path);
+ }
+
+ /**
+ * Get CacheUpstream .
+ *
+ * @param path the path
+ * @return the cacheUpstream
+ */
+ public CacheUpstream getUpstream(final String path) {
+ return UPSTREAM_CACHE_MAP.get(path);
+ }
+
+ /**
+ * Remove ICache .
+ *
+ * @param path the path
+ */
+ public void invalidateCache(final String path) {
+ ICache cache = CONFIG_CACHE_MAP.get(path);
+ if (!Objects.isNull(cache)) {
+ cache.close();
+ CONFIG_CACHE_MAP.remove(path);
+ UPSTREAM_CACHE_MAP.remove(path);
+ }
+ }
+
+ /**
+ * Invalidate all.
+ */
+ public void invalidateAll() {
+ if (CONFIG_CACHE_MAP.isEmpty()) {
+ return;
+ }
+
+ CONFIG_CACHE_MAP.forEach((key, cache) -> {
+ try {
+ if (!Objects.isNull(cache)) {
+ cache.close();
+ }
+ } catch (Exception e) {
+ LOG.error("Failed to close upstream {}", key, e);
+ }
+ });
+
+ UPSTREAM_CACHE_MAP.clear();
+ CONFIG_CACHE_MAP.clear();
+ }
+
+ /**
+ * Gets instance.
+ *
+ * @return the instance
+ */
+ public static ApplicationConfigCache getInstance() {
+ return ApplicationConfigCacheInstance.INSTANCE;
+ }
+
+ /**
+ * The type Application config cache instance.
+ */
+ static final class ApplicationConfigCacheInstance {
+ /**
+ * The Instance.
+ */
+ static final ApplicationConfigCache INSTANCE = new
ApplicationConfigCache();
+
+ private ApplicationConfigCacheInstance() {
+
+ }
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/handler/CachePluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/handler/CachePluginDataHandler.java
index 3ef7819c9a..40e5e12755 100644
---
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/handler/CachePluginDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/main/java/org/apache/shenyu/plugin/cache/handler/CachePluginDataHandler.java
@@ -22,6 +22,7 @@ import org.apache.shenyu.common.dto.PluginData;
import org.apache.shenyu.common.dto.RuleData;
import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.rule.impl.CacheRuleHandle;
+import org.apache.shenyu.common.dto.convert.selector.CacheUpstream;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.common.utils.Singleton;
@@ -31,6 +32,7 @@ import org.apache.shenyu.plugin.base.utils.BeanHolder;
import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
import org.apache.shenyu.plugin.cache.ICache;
import org.apache.shenyu.plugin.cache.ICacheBuilder;
+import org.apache.shenyu.plugin.cache.cache.ApplicationConfigCache;
import org.apache.shenyu.plugin.cache.config.CacheConfig;
import org.apache.shenyu.plugin.cache.utils.CacheUtils;
import org.apache.shenyu.spi.ExtensionLoader;
@@ -87,6 +89,11 @@ public class CachePluginDataHandler implements
PluginDataHandler {
@Override
public void handlerSelector(final SelectorData selectorData) {
+ CacheUpstream nCacheUpstream =
GsonUtils.getInstance().fromJson(selectorData.getHandle(), CacheUpstream.class);
+ CacheUpstream oCacheUpstream =
ApplicationConfigCache.getInstance().getUpstream(selectorData.getId());
+ if (Objects.nonNull(oCacheUpstream) && !Objects.equals(nCacheUpstream,
oCacheUpstream)) {
+
ApplicationConfigCache.getInstance().invalidateCache(selectorData.getId());
+ }
if (!selectorData.getContinued()) {
CACHED_HANDLE.get().cachedHandle(CacheKeyUtils.INST.getKey(selectorData.getId(),
Constants.DEFAULT_RULE), CacheRuleHandle.newInstance());
}
@@ -94,6 +101,7 @@ public class CachePluginDataHandler implements
PluginDataHandler {
@Override
public void removeSelector(final SelectorData selectorData) {
+
ApplicationConfigCache.getInstance().invalidateCache(selectorData.getId());
CACHED_HANDLE.get().removeHandle(CacheKeyUtils.INST.getKey(selectorData.getId(),
Constants.DEFAULT_RULE));
}
@@ -120,6 +128,7 @@ public class CachePluginDataHandler implements
PluginDataHandler {
*/
private void closeCacheIfNeed() {
ICache lastCache = CacheUtils.getCache();
+ ApplicationConfigCache.getInstance().invalidateAll();
if (Objects.nonNull(lastCache)) {
// close last cache.
LOG.info("close the last cache {}", lastCache);
diff --git
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/ApplicationConfigCacheTest.java
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/ApplicationConfigCacheTest.java
new file mode 100644
index 0000000000..d7ad8948a4
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/ApplicationConfigCacheTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.cache;
+
+import org.apache.shenyu.common.dto.MetaData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.dto.convert.selector.CacheUpstream;
+import org.apache.shenyu.common.enums.RpcTypeEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.plugin.cache.cache.ApplicationConfigCache;
+import org.apache.shenyu.plugin.cache.memory.MemoryCache;
+import org.apache.shenyu.plugin.cache.redis.RedisCache;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * ApplicationConfigCacheTest.
+ */
+@ExtendWith(MockitoExtension.class)
+public class ApplicationConfigCacheTest {
+
+ private ApplicationConfigCache cache;
+
+ private MetaData metaData;
+
+ private SelectorData selectorData;
+
+ @BeforeEach
+ void setUp() {
+ metaData = new MetaData();
+ metaData.setId("1332017966661636096");
+ metaData.setAppName("cache");
+ metaData.setPath("/http/findAll");
+
metaData.setServiceName("org.apache.shenyu.test.http.api.service.httpTestService");
+ metaData.setMethodName("findAll");
+ metaData.setRpcType(RpcTypeEnum.HTTP.getName());
+ selectorData = SelectorData.builder().id("153153464562434")
+ .handle("{\n"
+ + " \"cacheType\": \"redis\",\n"
+ + " \"url\": \"localhost:6379\",\n"
+ + " \"password\": \"shenyu123\",\n"
+ + " \"database\": \"0\",\n"
+ + " \"master\": \"mymaster\",\n"
+ + " \"mode\": \"sentinel\",\n"
+ + " \"maxIdle\": 8,\n"
+ + " \"minIdle\": 2,\n"
+ + " \"maxActive\": 100,\n"
+ + " \"maxWait\": 3000,\n"
+ + " \"protocol\": \"redis\",\n"
+ + " \"upstreamHost\": \"127.0.0.1\",\n"
+ + " \"upstreamUrl\": \"localhost:6379\",\n"
+ + " \"weight\": 100,\n"
+ + " \"status\": true,\n"
+ + " \"timestamp\": 1688611200000\n"
+ + "}").build();
+
+ cache = ApplicationConfigCache.getInstance();
+ cache.invalidateAll();
+ }
+
+ @Test
+ public void testInit() {
+ CacheUpstream cacheUpstream =
GsonUtils.getInstance().fromJson(selectorData.getHandle(), CacheUpstream.class);
+ ICache redisCache = cache.init(selectorData.getId(), cacheUpstream);
+ assertNotNull(redisCache);
+ assertTrue(redisCache instanceof RedisCache);
+ cache.invalidateAll();
+ cacheUpstream.setCacheType("memory");
+ ICache memCache = cache.init(selectorData.getId(), cacheUpstream);
+ assertNotNull(memCache);
+ assertTrue(memCache instanceof MemoryCache);
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/CachePluginTest.java
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/CachePluginTest.java
index cefcf3bc80..891f1cdfa6 100644
---
a/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/CachePluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler/src/test/java/org/apache/shenyu/plugin/cache/CachePluginTest.java
@@ -18,6 +18,7 @@
package org.apache.shenyu.plugin.cache;
import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.rule.impl.CacheRuleHandle;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.Singleton;
@@ -83,7 +84,7 @@ public class CachePluginTest {
MockClientHttpResponse clientResponse = new
MockClientHttpResponse(HttpStatus.OK);
clientResponse.setBody("body");
final CacheRuleHandle cacheRuleHandle = new CacheRuleHandle();
- CachePlugin.CacheHttpResponse cacheHttpResponse = new
CachePlugin.CacheHttpResponse(exchange, cacheRuleHandle);
+ CachePlugin.CacheHttpResponse cacheHttpResponse = new
CachePlugin.CacheHttpResponse(exchange, cacheRuleHandle, "");
cacheHttpResponse.getHeaders().add("Content-Type",
MediaType.APPLICATION_JSON_VALUE);
final Mono<Void> mono =
cacheHttpResponse.writeWith(clientResponse.getBody());
StepVerifier.create(mono).expectSubscription().verifyComplete();
@@ -97,11 +98,12 @@ public class CachePluginTest {
final RuleData ruleData = new RuleData();
CachePluginDataHandler.CACHED_HANDLE.get().cachedHandle(CacheKeyUtils.INST.getKey(ruleData),
new CacheRuleHandle());
Mockito.when(shenyuPluginChain.execute(any())).thenReturn(Mono.empty());
- final Mono<Void> result = cachePlugin.doExecute(exchange,
shenyuPluginChain, null, ruleData);
+ SelectorData selectorData = mock(SelectorData.class);
+ final Mono<Void> result = cachePlugin.doExecute(exchange,
shenyuPluginChain, selectorData, ruleData);
StepVerifier.create(result).expectSubscription().verifyComplete();
final MemoryCache memoryCache = new MemoryCache();
Singleton.INST.single(ICache.class, memoryCache);
- final Mono<Void> result2 = cachePlugin.doExecute(exchange,
shenyuPluginChain, null, ruleData);
+ final Mono<Void> result2 = cachePlugin.doExecute(exchange,
shenyuPluginChain, selectorData, ruleData);
StepVerifier.create(result2).expectSubscription().verifyComplete();
memoryCache.cacheData(CacheUtils.dataKey(exchange),
MediaType.APPLICATION_JSON_VALUE.getBytes(StandardCharsets.UTF_8),
@@ -109,7 +111,7 @@ public class CachePluginTest {
memoryCache.cacheData(CacheUtils.contentTypeKey(exchange),
MediaType.APPLICATION_JSON_VALUE.getBytes(StandardCharsets.UTF_8),
60L).subscribeOn(Schedulers.boundedElastic()).subscribe();
- final Mono<Void> result3 = cachePlugin.doExecute(exchange,
shenyuPluginChain, null, ruleData);
+ final Mono<Void> result3 = cachePlugin.doExecute(exchange,
shenyuPluginChain, selectorData, ruleData);
StepVerifier.create(result3).expectSubscription().verifyComplete();
}