You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ni...@apache.org on 2026/02/02 03:38:24 UTC
(apisix) branch master updated: chore: add redis prefix to keepalive settings (#12955)
This is an automated email from the ASF dual-hosted git repository.
nic443 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 470dbf8d2 chore: add redis prefix to keepalive settings (#12955)
470dbf8d2 is described below
commit 470dbf8d2a3e95f0b219736d7938c0dbf8874312
Author: Nic <qi...@api7.ai>
AuthorDate: Mon Feb 2 11:38:19 2026 +0800
chore: add redis prefix to keepalive settings (#12955)
Signed-off-by: Nic <qi...@api7.ai>
---
apisix/plugins/limit-conn/limit-conn-redis.lua | 4 ++--
apisix/plugins/limit-count/limit-count-redis.lua | 2 +-
apisix/plugins/limit-req/limit-req-redis.lua | 2 +-
apisix/utils/redis-schema.lua | 8 ++++----
apisix/utils/rediscluster.lua | 4 ++--
docs/en/latest/plugins/limit-conn.md | 4 ++--
docs/en/latest/plugins/limit-count.md | 4 ++--
docs/en/latest/plugins/limit-req.md | 4 ++--
docs/zh/latest/plugins/limit-conn.md | 4 ++--
docs/zh/latest/plugins/limit-count.md | 4 ++--
docs/zh/latest/plugins/limit-req.md | 4 ++--
t/plugin/limit-conn-redis-cluster.t | 4 ++--
t/plugin/limit-count-redis-cluster3.t | 4 ++--
t/plugin/limit-req-redis-cluster.t | 4 ++--
14 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/apisix/plugins/limit-conn/limit-conn-redis.lua b/apisix/plugins/limit-conn/limit-conn-redis.lua
index 2dc15f879..b28734210 100644
--- a/apisix/plugins/limit-conn/limit-conn-redis.lua
+++ b/apisix/plugins/limit-conn/limit-conn-redis.lua
@@ -51,7 +51,7 @@ function _M.incoming(self, key, commit)
return red, err
end
local delay, incoming_err = util.incoming(self, red, key, commit)
- local ok, err = red:set_keepalive(conf.keepalive_timeout, conf.keepalive_pool)
+ local ok, err = red:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)
if not ok then
core.log.error("set keepalive failed: ", err)
end
@@ -72,7 +72,7 @@ local function leaving_thread(premature, self, key, req_latency, req_id)
return red, err
end
local conn, leaving_err = util.leaving(self, red, key, req_latency, req_id)
- local ok, err = red:set_keepalive(conf.keepalive_timeout, conf.keepalive_pool)
+ local ok, err = red:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)
if not ok then
core.log.error("set keepalive failed: ", err)
end
diff --git a/apisix/plugins/limit-count/limit-count-redis.lua b/apisix/plugins/limit-count/limit-count-redis.lua
index a68de7fbb..ce78383fe 100644
--- a/apisix/plugins/limit-count/limit-count-redis.lua
+++ b/apisix/plugins/limit-count/limit-count-redis.lua
@@ -74,7 +74,7 @@ function _M.incoming(self, key, cost)
local remaining = res[1]
ttl = res[2]
- local ok, err = red:set_keepalive(conf.keepalive_timeout, conf.keepalive_pool)
+ local ok, err = red:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)
if not ok then
return nil, err, ttl
end
diff --git a/apisix/plugins/limit-req/limit-req-redis.lua b/apisix/plugins/limit-req/limit-req-redis.lua
index f35eaa155..fe7fb739c 100644
--- a/apisix/plugins/limit-req/limit-req-redis.lua
+++ b/apisix/plugins/limit-req/limit-req-redis.lua
@@ -47,7 +47,7 @@ function _M.incoming(self, key, commit)
end
local delay, incoming_err = util.incoming(self, red, key, commit)
- local ok, err = red:set_keepalive(conf.keepalive_timeout, conf.keepalive_pool)
+ local ok, err = red:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)
if not ok then
core.log.error("set keepalive failed: ", err)
end
diff --git a/apisix/utils/redis-schema.lua b/apisix/utils/redis-schema.lua
index 979b50220..0a884ca81 100644
--- a/apisix/utils/redis-schema.lua
+++ b/apisix/utils/redis-schema.lua
@@ -42,10 +42,10 @@ local policy_to_additional_properties = {
redis_ssl_verify = {
type = "boolean", default = false,
},
- keepalive_timeout = {
+ redis_keepalive_timeout = {
type = "integer", minimum = 1000, default = 10000
},
- keepalive_pool = {
+ redis_keepalive_pool = {
type = "integer", minimum = 1, default = 100
}
},
@@ -75,10 +75,10 @@ local policy_to_additional_properties = {
redis_cluster_ssl_verify = {
type = "boolean", default = false,
},
- keepalive_timeout = {
+ redis_keepalive_timeout = {
type = "integer", minimum = 1000, default = 10000
},
- keepalive_pool = {
+ redis_keepalive_pool = {
type = "integer", minimum = 1, default = 100
}
},
diff --git a/apisix/utils/rediscluster.lua b/apisix/utils/rediscluster.lua
index 46c1b09d9..9c058c4dc 100644
--- a/apisix/utils/rediscluster.lua
+++ b/apisix/utils/rediscluster.lua
@@ -24,8 +24,8 @@ local function new_redis_cluster(conf, dict_name)
local config = {
name = conf.redis_cluster_name,
serv_list = {},
- keepalive_timeout = conf.keepalive_timeout, -- redis connection pool idle timeout
- keepalive_cons = conf.keepalive_pool, -- redis connection pool size
+ keepalive_timeout = conf.redis_keepalive_timeout, -- redis connection pool idle timeout
+ keepalive_cons = conf.redis_keepalive_pool, -- redis connection pool size
connect_timeout = conf.redis_timeout,
read_timeout = conf.redis_timeout,
send_timeout = conf.redis_timeout,
diff --git a/docs/en/latest/plugins/limit-conn.md b/docs/en/latest/plugins/limit-conn.md
index 32118ee0d..2d7b07884 100644
--- a/docs/en/latest/plugins/limit-conn.md
+++ b/docs/en/latest/plugins/limit-conn.md
@@ -57,8 +57,8 @@ The `limit-conn` Plugin limits the rate of requests by the number of concurrent
| redis_ssl_verify | boolean | False | false | | If true, verify the server SSL certificate when `policy` is `redis`. |
| redis_database | integer | False | 0 | >= 0 | The database number in Redis when `policy` is `redis`. |
| redis_timeout | integer | False | 1000 | [1,...] | The Redis timeout value in milliseconds when `policy` is `redis` or `redis-cluster`. |
-| keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
-| keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`.|
+| redis_keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
+| redis_keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`.|
| redis_cluster_nodes | array[string] | False | | | The list of the Redis cluster nodes with at least two addresses. Required when policy is redis-cluster. |
| redis_cluster_name | string | False | | | The name of the Redis cluster. Required when `policy` is `redis-cluster`. |
| redis_cluster_ssl | boolean | False | false | | If true, use SSL to connect to Redis cluster when `policy` is |
diff --git a/docs/en/latest/plugins/limit-count.md b/docs/en/latest/plugins/limit-count.md
index d68768ac6..3f872c215 100644
--- a/docs/en/latest/plugins/limit-count.md
+++ b/docs/en/latest/plugins/limit-count.md
@@ -62,8 +62,8 @@ You may see the following rate limiting headers in the response:
| redis_ssl_verify | boolean | False | false | | If true, verify the server SSL certificate when `policy` is `redis`. [...]
| redis_database | integer | False | 0 | >= 0 | The database number in Redis when `policy` is `redis`. |
| redis_timeout | integer | False | 1000 | [1,...] | The Redis timeout value in milliseconds when `policy` is `redis` or `redis-cluster`. [...]
-| keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
-| keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`. |
+| redis_keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
+| redis_keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`. |
| redis_cluster_nodes | array[string] | False | | | The list of the Redis cluster nodes with at least two addresses. Required when policy is redis-cluster. [...]
| redis_cluster_name | string | False | | | The name of the Redis cluster. Required when `policy` is `redis-cluster`. [...]
| redis_cluster_ssl | boolean | False | false | | If true, use SSL to connect to Redis cluster when `policy` is `redis-cluster`. [...]
diff --git a/docs/en/latest/plugins/limit-req.md b/docs/en/latest/plugins/limit-req.md
index 1d378a61b..c8af97665 100644
--- a/docs/en/latest/plugins/limit-req.md
+++ b/docs/en/latest/plugins/limit-req.md
@@ -56,8 +56,8 @@ The `limit-req` Plugin uses the [leaky bucket](https://en.wikipedia.org/wiki/Lea
| redis_ssl_verify | boolean | False | false | | If true, verify the server SSL certificate when `policy` is `redis`. |
| redis_database | integer | False | 0 | >= 0 | The database number in Redis when `policy` is `redis`. |
| redis_timeout | integer | False | 1000 | [1,...] | The Redis timeout value in milliseconds when `policy` is `redis` or `redis-cluster`. |
-| keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
-| keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`. |
+| redis_keepalive_timeout | integer | False | 10000 | ≥ 1000 | Keepalive timeout in milliseconds for redis when `policy` is `redis` or `redis-cluster`. |
+| redis_keepalive_pool | integer | False | 100 | ≥ 1 | Keepalive pool size for redis when `policy` is `redis` or `redis-cluster`. |
| redis_cluster_nodes | array[string] | False | | | The list of the Redis cluster nodes with at least two addresses. Required when policy is redis-cluster. |
| redis_cluster_name | string | False | | | The name of the Redis cluster. Required when `policy` is `redis-cluster`. |
| redis_cluster_ssl | boolean | False | false | | If true, use SSL to connect to Redis cluster when `policy` is |
diff --git a/docs/zh/latest/plugins/limit-conn.md b/docs/zh/latest/plugins/limit-conn.md
index d0980c258..66836a23c 100644
--- a/docs/zh/latest/plugins/limit-conn.md
+++ b/docs/zh/latest/plugins/limit-conn.md
@@ -57,8 +57,8 @@ description: limit-conn 插件通过管理并发连接来限制请求速率。
| redis_ssl_verify | boolean | 否 | false | | 如果为 true,则在 `policy` 为 `redis` 时验证服务器 SSL 证书。|
| redis_database | integer | 否 | 0 | >= 0 | 当 `policy` 为 `redis` 时,Redis 中的数据库编号。|
| redis_timeout | integer | 否 | 1000 | [1,...] | 当 `policy` 为 `redis` 或 `redis-cluster` 时,Redis 超时值(以毫秒为单位)。 |
-| keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
-| keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
+| redis_keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
+| redis_keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
| redis_cluster_nodes | array[string] | 否 | | | 具有至少两个地址的 Redis 群集节点列表。当 policy 为 redis-cluster 时必填。 |
redis_cluster_name | string | 否 | | | | Redis 集群的名称。当 `policy` 为 `redis-cluster` 时必须使用。|
| redis_cluster_ssl | boolean | 否 | false | | 如果为 `true`,当 `policy` 为 `redis-cluster`时,使用 SSL 连接 Redis 集群。|
diff --git a/docs/zh/latest/plugins/limit-count.md b/docs/zh/latest/plugins/limit-count.md
index 615390b26..44fe97970 100644
--- a/docs/zh/latest/plugins/limit-count.md
+++ b/docs/zh/latest/plugins/limit-count.md
@@ -63,8 +63,8 @@ description: limit-count 插件使用固定窗口算法,通过给定时间间
| redis_ssl_verify | boolean | 否 | false | | 如果为 true,则在 `policy` 为 `redis` 时验证服务器 SSL 证书。|
| redis_database | integer | 否 | 0 | >= 0 | 当 `policy` 为 `redis` 时,Redis 中的数据库编号。|
| redis_timeout | integer | 否 | 1000 | [1,...] | 当 `policy` 为 `redis` 或 `redis-cluster` 时,Redis 超时值(以毫秒为单位)。 |
-| keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
-| keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
+| redis_keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
+| redis_keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
| redis_cluster_nodes | array[string] | 否 | | | 具有至少两个地址的 Redis 群集节点列表。当 policy 为 redis-cluster 时必填。 |
redis_cluster_name | string | 否 | | | | Redis 集群的名称。当 `policy` 为 `redis-cluster` 时必须使用。|
| redis_cluster_ssl | boolean | 否 | false | | 如果为 `true`,当 `policy` 为 `redis-cluster`时,使用 SSL 连接 Redis 集群。|
diff --git a/docs/zh/latest/plugins/limit-req.md b/docs/zh/latest/plugins/limit-req.md
index 8ab9fed25..7c7169c02 100644
--- a/docs/zh/latest/plugins/limit-req.md
+++ b/docs/zh/latest/plugins/limit-req.md
@@ -58,8 +58,8 @@ description: limit-req 插件使用漏桶算法来限制请求的数量并允许
| redis_ssl_verify | boolean | 否 | false | | 如果为 true,则在 `policy` 为 `redis` 时验证服务器 SSL 证书。|
| redis_database | integer | 否 | 0 | >= 0 | 当 `policy` 为 `redis` 时,Redis 中的数据库编号。|
| redis_timeout | integer | 否 | 1000 | [1,...] | 当 `policy` 为 `redis` 或 `redis-cluster` 时,Redis 超时值(以毫秒为单位)。 |
-| keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
-| keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
+| redis_keepalive_timeout | integer | 否 | 10000 | ≥ 1000 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的空闲连接超时时间,单位为毫秒。|
+| redis_keepalive_pool | integer | 否 | 100 | ≥ 1 | 当 `policy` 为 `redis` 或 `redis-cluster` 时,与 `redis` 或 `redis-cluster` 的连接池最大连接数。|
| redis_cluster_nodes | array[string] | 否 | | | 具有至少两个地址的 Redis 群集节点列表。当 policy 为 redis-cluster 时必填。 |
redis_cluster_name | string | 否 | | | | Redis 集群的名称。当 `policy` 为 `redis-cluster` 时必须使用。|
| redis_cluster_ssl | boolean | 否 | false | | 如果为 `true`,当 `policy` 为 `redis-cluster`时,使用 SSL 连接 Redis 集群。|
diff --git a/t/plugin/limit-conn-redis-cluster.t b/t/plugin/limit-conn-redis-cluster.t
index 12147bfb8..f2ae5b5d5 100644
--- a/t/plugin/limit-conn-redis-cluster.t
+++ b/t/plugin/limit-conn-redis-cluster.t
@@ -357,8 +357,8 @@ status:503, count:4
"127.0.0.1:7002",
"127.0.0.1:7000"
},
- keepalive_timeout = 10000,
- keepalive_pool = 100,
+ redis_keepalive_timeout = 10000,
+ redis_keepalive_pool = 100,
redis_cluster_name = "redis-cluster-2",
redis_cluster_ssl = true,
redis_cluster_ssl_verify = false
diff --git a/t/plugin/limit-count-redis-cluster3.t b/t/plugin/limit-count-redis-cluster3.t
index dc6842494..dfb6af1f4 100644
--- a/t/plugin/limit-count-redis-cluster3.t
+++ b/t/plugin/limit-count-redis-cluster3.t
@@ -198,8 +198,8 @@ passed
key = "remote_addr",
policy = "redis-cluster",
redis_timeout = 1001,
- keepalive_timeout = 10000,
- keepalive_pool = 100,
+ redis_keepalive_timeout = 10000,
+ redis_keepalive_pool = 100,
redis_cluster_nodes = {
"127.0.0.1:5000"
},
diff --git a/t/plugin/limit-req-redis-cluster.t b/t/plugin/limit-req-redis-cluster.t
index 8336858d8..61750d54c 100644
--- a/t/plugin/limit-req-redis-cluster.t
+++ b/t/plugin/limit-req-redis-cluster.t
@@ -621,8 +621,8 @@ qr/property \"rate\" validation failed: expected 0 to be greater than 0/
"127.0.0.1:5000",
"127.0.0.1:5002"
},
- keepalive_timeout = 10000,
- keepalive_pool = 100
+ redis_keepalive_timeout = 10000,
+ redis_keepalive_pool = 100
}
local lim = lim_req_redis_cluster.new("limit-req", conf, 2, 1)
local redis_conf = lim.red_cli.config