You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by qi...@apache.org on 2022/04/03 03:42:39 UTC

[incubator-shenyu-website] branch main updated: add cache plugin doc (#531)

This is an automated email from the ASF dual-hosted git repository.

qicz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git


The following commit(s) were added to refs/heads/main by this push:
     new ece9091  add cache plugin doc (#531)
ece9091 is described below

commit ece9091d4dc28f99a48e17acb6a3ed123946538e
Author: zouchangfu <50...@users.noreply.github.com>
AuthorDate: Sun Apr 3 11:42:35 2022 +0800

    add cache plugin doc (#531)
    
    * add cache plugin doc
    
    * format doc
    
    * format doc
    
    * format doc
---
 docs/plugin-center/cache/_category_.json           |   4 +
 docs/plugin-center/cache/cache-plugin.md           |  81 +++++++++++++++++++++
 .../current/plugin-center/cache/_category_.json    |   4 +
 .../current/plugin-center/cache/cache-plugin.md    |  77 ++++++++++++++++++++
 static/img/shenyu/plugin/cache/cache-plugin-en.png | Bin 0 -> 28979 bytes
 .../shenyu/plugin/cache/cache-plugin-handle-en.png | Bin 0 -> 13976 bytes
 .../shenyu/plugin/cache/cache-plugin-handle-zh.png | Bin 0 -> 14121 bytes
 .../shenyu/plugin/cache/cache-plugin-rule-en.png   | Bin 0 -> 24270 bytes
 .../shenyu/plugin/cache/cache-plugin-rule-zh.png   | Bin 0 -> 25440 bytes
 static/img/shenyu/plugin/cache/cache-plugin-zh.png | Bin 0 -> 31950 bytes
 10 files changed, 166 insertions(+)

diff --git a/docs/plugin-center/cache/_category_.json b/docs/plugin-center/cache/_category_.json
new file mode 100644
index 0000000..8768a0f
--- /dev/null
+++ b/docs/plugin-center/cache/_category_.json
@@ -0,0 +1,4 @@
+{
+  "label": "Cache",
+  "position": 7
+}
diff --git a/docs/plugin-center/cache/cache-plugin.md b/docs/plugin-center/cache/cache-plugin.md
new file mode 100644
index 0000000..4097c84
--- /dev/null
+++ b/docs/plugin-center/cache/cache-plugin.md
@@ -0,0 +1,81 @@
+---
+title: Cache Plugin
+keywords: ["Cache"]
+description: Cache Plugin
+---
+
+## Description
+
+* The `Cache`plugin is able to cache theesults of the target service, allowing the user to configure the expiration
+  time of the cached results.
+
+## Plugin Setting
+
+In `shenyu-admin` --> BasicConfig --> plugin --> `Cache` set to enable.
+![](/img/shenyu/plugin/cache/cache-plugin-en.png)
+
+Cache currently supports two modes of caching data.
+
+* memory:local memory mode
+
+* redis:redis mode
+  ![](/img/shenyu/plugin/cache/cache-plugin-handle-en.png)
+
+The current default is `local memory mode`, the results of the target service are stored in the local memory, if the
+gateway is deployed by way of cluster, it is not recommended to use `local memory mode`, it is recommended to
+use `redis mode`, the data of the target service are cached in redis.
+
+If you are using `local memory mode`, you only need to select memory in cacheType, no other configuration is needed.
+
+If you are using `redis mode`, select redis in cacheType, and the parameters are as follows
+
+* database: which database the cache results are stored in, the default is index database 0.
+
+* master: default is master.
+
+* mode: the working mode of redis, the default is single-point mode: `standalone`, in addition to cluster
+  mode: `cluster`, sentinel mode: `sentinel`.
+
+* url: configure the IP and port of the redis database, configured by colon connection, example: `192.168.1.1:6379`.
+
+* password: the password of the redis database, if not, you can not configure.
+
+* maxldle: the maximum free connections in the connection pool
+
+* minldle: minimum idle connections in the connection pool
+
+* maxActive: the maximum number of connections in the connection pool
+
+* maxWait: the maximum blocking wait time for the connection pool (use negative values to indicate no limit) default -1
+
+## Plugin Use
+
+* Add support for `Cache` in the `pom.xml` file of shenyu-bootstrap.
+
+```xml
+        <!--shenyu cache plugin start-->
+<dependency>
+    <groupId>org.apache.shenyu</groupId>
+    <artifactId>shenyu-spring-boot-starter-plugin-cache</artifactId>
+    <version>${project.version}</version>
+</dependency>
+        <!--shenyu cache plugin end-->
+```
+
+* Selectors and rules, please refer
+  to: [Selector And Rule Config](https://shenyu.apache.org/docs/plugin-center/user-guide/admin-usage/selector-and-rule "Selector And Rule Config")
+  .
+
+* Only matching requests will be cached by the Cache plugin for the results of the target service.
+
+The parameter `timeoutSecods` in the rule, the value is the target service result data cache time, the default is 60,
+in `seconds`.
+![](/img/shenyu/plugin/cache/cache-plugin-rule-en.png)
+
+Note: The current version of the Cache plugin uses the url as a unique key to identify the same request.
+
+## Situation
+
+* Situation where data is not updated frequently and a large number of calls are required.
+
+* For Situation where data consistency is not required.
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/_category_.json
new file mode 100644
index 0000000..1452462
--- /dev/null
+++ b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/_category_.json
@@ -0,0 +1,4 @@
+{
+  "label": "缓存123",
+  "position": 7
+}
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/cache-plugin.md b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/cache-plugin.md
new file mode 100644
index 0000000..9f372cd
--- /dev/null
+++ b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/cache/cache-plugin.md
@@ -0,0 +1,77 @@
+---
+title: 缓存插件
+keywords: ["缓存"]
+description: 缓存插件
+---
+
+## 说明
+
+* `Cache`插件能够缓存目标服务的结果,允许用户配置缓存结果的失效时间。
+
+## 插件配置
+
+在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `Cache` 设置为开启。
+
+![](/img/shenyu/plugin/cache/cache-plugin-zh.png)
+
+Cache目前支持两种模式缓存数据:
+
+* memory:本地内存模式
+
+* redis:redis模式
+
+![](/img/shenyu/plugin/cache/cache-plugin-handle-zh.png)
+
+目前默认的是`本地内存模式`,目标服务的结果都存储在本地内存中,如果网关是通过集群的方式部署的,不建议使用`本地内存模式`,推荐使用`redis模式`,目标服务的数据都缓存到redis中。
+
+如果使用的是`本地内存模式`,只需要在cacheType中选择memory即可,其他配置都不需要配置。
+
+如果使用的是`redis模式`,在cacheType中选择redis,参数介绍:
+
+* database:缓存结果存储到哪个数据库中,默认是索引库0。
+
+* master:默认为master。
+
+* mode:redis的工作模式,默认为单点模式:`standalone`,此外还有集群模式:`cluster`,哨兵模式:`sentinel`。
+
+* url:配置 redis 数据库的IP和端口,通过冒号连接配置,示例:`192.168.1.1:6379`。
+
+* password: redis 数据库的密码,如果没有的话,可以不配置。
+
+* maxldle:连接池中最大空闲连接
+
+* minldle:连接池中最小空闲连接
+
+* maxActive:连接池最大连接数
+
+* maxWait:连接池最大阻塞等待时间(使用负值表示没有限制)默认 -1
+
+## 插件使用
+
+* 在网关的 `pom.xml` 文件中添加 `Cache` 的支持。
+
+```xml
+        <!--shenyu cache plugin start-->
+<dependency>
+    <groupId>org.apache.shenyu</groupId>
+    <artifactId>shenyu-spring-boot-starter-plugin-cache</artifactId>
+    <version>${project.version}</version>
+</dependency>
+        <!--shenyu cache plugin end-->
+```
+
+* 选择器和规则设置,请参考:[选择器和规则管理](https://shenyu.apache.org/zh/docs/user-guide/admin-usage/selector-and-rule "选择器和规则管理")。
+
+* 只有匹配的请求,`Cache`插件才会对目标服务的结果进行缓存。
+
+规则中参数 `timeoutSecods`,该值为目标服务结果数据缓存时间,默认是60,单位`秒`。
+
+![](/img/shenyu/plugin/cache/cache-plugin-rule-zh.png)
+
+注意:当前版本的Cache插件是把url作为唯一key,标识同一个请求的。
+
+## 使用场景
+
+* 数据不会频繁更新,而且需要大量调用的场景。
+
+* 对于数据一致性要求不高的场景。
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-en.png b/static/img/shenyu/plugin/cache/cache-plugin-en.png
new file mode 100644
index 0000000..377aed1
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-en.png differ
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-handle-en.png b/static/img/shenyu/plugin/cache/cache-plugin-handle-en.png
new file mode 100644
index 0000000..c4a1222
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-handle-en.png differ
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-handle-zh.png b/static/img/shenyu/plugin/cache/cache-plugin-handle-zh.png
new file mode 100644
index 0000000..9201519
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-handle-zh.png differ
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-rule-en.png b/static/img/shenyu/plugin/cache/cache-plugin-rule-en.png
new file mode 100644
index 0000000..904aa76
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-rule-en.png differ
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-rule-zh.png b/static/img/shenyu/plugin/cache/cache-plugin-rule-zh.png
new file mode 100644
index 0000000..5e07bcc
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-rule-zh.png differ
diff --git a/static/img/shenyu/plugin/cache/cache-plugin-zh.png b/static/img/shenyu/plugin/cache/cache-plugin-zh.png
new file mode 100644
index 0000000..e23e9d4
Binary files /dev/null and b/static/img/shenyu/plugin/cache/cache-plugin-zh.png differ