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

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


The following commit(s) were added to refs/heads/main by this push:
     new 73cffb4d2 [type:feat] add cache config (#880)
73cffb4d2 is described below

commit 73cffb4d26721ab308a49a7fb322f7519961d642
Author: moremind <[email protected]>
AuthorDate: Fri Mar 24 14:38:04 2023 +0800

    [type:feat] add cache config (#880)
---
 docs/deployment/deployment-k8s.md                  | 28 +++++++++++--
 .../property-config/gateway-property-config.md     | 47 ++++++++++++++++++----
 .../current/deployment/deployment-k8s.md           | 28 +++++++++++--
 .../property-config/gateway-property-config.md     | 46 +++++++++++++++++----
 4 files changed, 127 insertions(+), 22 deletions(-)

diff --git a/docs/deployment/deployment-k8s.md 
b/docs/deployment/deployment-k8s.md
index c8e0733a0..2470e1c71 100644
--- a/docs/deployment/deployment-k8s.md
+++ b/docs/deployment/deployment-k8s.md
@@ -175,8 +175,18 @@ data:
           enabled: false
     shenyu:
       matchCache:
-        enabled: false
-        maxFreeMemory: 256 # 256MB
+        selector:
+          selectorEnabled: false
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+        rule:
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+      trie:
+        childrenSize: 10000
+        pathVariableSize: 1000
+        pathRuleCacheSize: 1000
+        matchMode: antPathMatch
       netty:
         http:
           # set to false, user can custom the netty tcp server config.
@@ -568,8 +578,18 @@ data:
           enabled: false
     shenyu:
       matchCache:
-        enabled: false
-        maxFreeMemory: 256 # 256MB
+        selector:
+          selectorEnabled: false
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+        rule:
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+      trie:
+        childrenSize: 10000
+        pathVariableSize: 1000
+        pathRuleCacheSize: 1000
+        matchMode: antPathMatch
       netty:
         http:
           # set to false, user can custom the netty tcp server config.
diff --git a/docs/user-guide/property-config/gateway-property-config.md 
b/docs/user-guide/property-config/gateway-property-config.md
index 3f0ee2b9d..c207a1f48 100644
--- a/docs/user-guide/property-config/gateway-property-config.md
+++ b/docs/user-guide/property-config/gateway-property-config.md
@@ -13,8 +13,18 @@ This paper mainly explains how to configure `Apache ShenYu` 
properties on the ga
 ```yaml
 shenyu:
   matchCache:
-    enabled: false
-    maxFreeMemory: 256 # 256MB
+    selector:
+      selectorEnabled: false
+      initialCapacity: 10000 # initial capacity in cache
+      maximumSize: 10000 # max size in cache
+    rule:
+      initialCapacity: 10000 # initial capacity in cache
+      maximumSize: 10000 # max size in cache
+  trie:
+    childrenSize: 10000
+    pathVariableSize: 1000
+    pathRuleCacheSize: 1000
+    matchMode: antPathMatch
   netty:
     http:
       webServerFactoryEnabled: true
@@ -201,12 +211,35 @@ shenyu:
 
 ##### shenyu.matchCache config
 
-The apache shenyu  selector cache config.
+* selector cache
+
+| Field           | Type    | Default | Required | Description                 
        |
+|-----------------|---------|---------|----------|-------------------------------------|
+| selectorEnabled | Boolean | false   | No       | Whether to enable selector 
caching. |
+| initialCapacity | Integer | 10000   | No       | selector initial capacity   
        |
+| maximumSize     | Integer | 10000   | No       | selector max size           
        |
+
+* rule Level-1 cache config
+
+| Field           | Type    | Default | Required | Description           |
+|-----------------|---------|---------|----------|-----------------------|
+| initialCapacity | Integer | 10000   | Yes      | rule initial capacity |
+| maximumSize     | Integer | 10000   | Yes      | rule max size         |
+
+* shenyu rule Level-2 cache config(shenyu level-2 cache using trie cache)
+
+| Field             | Type    | Default      | Required | Description          
                                                             |
+|-------------------|---------|--------------|----------|-----------------------------------------------------------------------------------|
+| childrenSize      | Integer | 10000        | Yes      | trie cache children 
size                                                          |
+| pathVariableSize  | Integer | 1000         | Yes      | tie cache path 
variable size, for example, /{username}/{age}                      |
+| pathRuleCacheSize | Integer | 1000         | Yes      | rule data list of 
the current path                                                |
+| matchMode         | String  | antPathMatch | Yes      | path match mode, 
shenyu support two match modes, `antPathMatch` and `pathPattern` |
+
+L1 and L2 caching is enabled on shenyu by default,
+shenyu trie match support two match mode, we suggest use `pathPattern` as 
default match mode
 
-| Name          | Type    | Default | Required | Description                   
      |
-| :------------ | :------ | :-----: | :------: | 
:---------------------------------- |
-| enabled       | Boolean |  false  |    No    | Whether to enable selector 
caching. |
-| maxFreeMemory | Integer |  256MB  |   否No   | Maximum cache usage (MB).      
     |
+> pathPattern: org.springframework.web.util.pattern.PathPatternParser
+> antPathMatch: org.springframework.util.AntPathMatcher
 
 
 
diff --git 
a/i18n/zh/docusaurus-plugin-content-docs/current/deployment/deployment-k8s.md 
b/i18n/zh/docusaurus-plugin-content-docs/current/deployment/deployment-k8s.md
index fc8ea3493..c367c1e64 100644
--- 
a/i18n/zh/docusaurus-plugin-content-docs/current/deployment/deployment-k8s.md
+++ 
b/i18n/zh/docusaurus-plugin-content-docs/current/deployment/deployment-k8s.md
@@ -174,8 +174,18 @@ data:
           enabled: false
     shenyu:
       matchCache:
-        enabled: false
-        maxFreeMemory: 256 # 256MB
+        selector:
+          selectorEnabled: false
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+        rule:
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+      trie:
+        childrenSize: 10000
+        pathVariableSize: 1000
+        pathRuleCacheSize: 1000
+        matchMode: antPathMatch
       netty:
         http:
           # set to false, user can custom the netty tcp server config.
@@ -570,8 +580,18 @@ data:
           enabled: false
     shenyu:
       matchCache:
-        enabled: false
-        maxFreeMemory: 256 # 256MB
+        selector:
+          selectorEnabled: false
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+        rule:
+          initialCapacity: 10000 # initial capacity in cache
+          maximumSize: 10000 # max size in cache
+      trie:
+        childrenSize: 10000
+        pathVariableSize: 1000
+        pathRuleCacheSize: 1000
+        matchMode: antPathMatch
       netty:
         http:
           # set to false, user can custom the netty tcp server config.
diff --git 
a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/property-config/gateway-property-config.md
 
b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/property-config/gateway-property-config.md
index 17a87e81d..debdc47a4 100644
--- 
a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/property-config/gateway-property-config.md
+++ 
b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/property-config/gateway-property-config.md
@@ -13,8 +13,18 @@ description: 网关属性配置
 ```yaml
 shenyu:
   matchCache:
-    enabled: false
-    maxFreeMemory: 256 # 256MB
+    selector:
+      selectorEnabled: false
+      initialCapacity: 10000 # initial capacity in cache
+      maximumSize: 10000 # max size in cache
+    rule:
+      initialCapacity: 10000 # initial capacity in cache
+      maximumSize: 10000 # max size in cache
+  trie:
+    childrenSize: 10000
+    pathVariableSize: 1000
+    pathRuleCacheSize: 1000
+    matchMode: antPathMatch
   netty:
     http:
       webServerFactoryEnabled: true
@@ -201,12 +211,34 @@ shenyu:
 
 ##### shenyu.matchCache 配置
 
-Apache ShenYu 选择器缓存配置
+* Apache ShenYu 选择器缓存配置
 
-| 名称          | 类型    | 默认值 | 是否必填 | 说明 |
-|:------------------------------|:----- 
|:-------:|:--------:|:------------------------------------------------------------|
-| enabled | Boolean |  false  |    否    | 是否开启选择器缓存 |
-| maxFreeMemory | Integer | 256MB | 否 | 最大缓存占用,单位MB |
+| 字段           | 类型    | 默认值 | 是否必填 | 说明       |
+|-----------------|---------|---------|----------|-------------------|
+| selectorEnabled | Boolean | false   | No       | 是否开启选择器缓存         |
+| initialCapacity | Integer | 10000   | No       | 选择器缓存初始化容量        |
+| maximumSize     | Integer | 10000   | No       | 选择器缓存最大数量         |
+
+* Apache ShenYu L1级缓存配置
+
+| 字段              | 类型      | 默认值   | 是否必填 | 说明        |
+|-----------------|---------|-------|------|-----------|
+| initialCapacity | Integer | 10000 | Yes  | 规则缓存初始化容量 |
+| maximumSize     | Integer | 10000 | Yes  | 规则缓存最大容量  |
+
+* Apache ShenYu L2级缓存配置(shenyu使用前缀树作为l2缓存)
+
+| 字段                | 类型      | 默认值      | 是否必填 | 说明                           
                                 |
+|-------------------|---------|--------------|----------|---------------------------------------------------------------|
+| childrenSize      | Integer | 10000        | Yes      | 前缀树缓存每个子节点的缓存数量      
                                         |
+| pathVariableSize  | Integer | 1000         | Yes      | 前缀树缓存每个子节点存储的路径变量数量, 
/{username}/{age}                        |
+| pathRuleCacheSize | Integer | 1000         | Yes      | 当前路径的规则              
                                         |
+| matchMode         | String  | antPathMatch | Yes      | 
shenyu路径匹配模式,shenyu支持两种匹配模式: `antPathMatch` and `pathPattern` |
+
+shenyu默认开启L1和L2缓存, shenyu前缀树支持两种匹配模式,我们非常建议您使用`pathPattern`作为默认的匹配模式。
+
+> pathPattern: org.springframework.web.util.pattern.PathPatternParser
+> antPathMatch: org.springframework.util.AntPathMatcher
 
 
 

Reply via email to