mirror of
https://github.com/alibaba/higress.git
synced 2026-05-30 23:57:28 +08:00
improve the logic for constructing redis key (#1933)
This commit is contained in:
@@ -39,7 +39,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ClusterRateLimitFormat string = "higress-token-ratelimit:%s:%s:%s:%s"
|
ClusterRateLimitFormat string = "higress-token-ratelimit:%s:%s:%d:%d:%s:%s" // ruleName, limitType, timewindow, windowsize, key, val
|
||||||
RequestPhaseFixedWindowScript string = `
|
RequestPhaseFixedWindowScript string = `
|
||||||
local ttl = redis.call('ttl', KEYS[1])
|
local ttl = redis.call('ttl', KEYS[1])
|
||||||
if ttl < 0 then
|
if ttl < 0 then
|
||||||
@@ -103,7 +103,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config ClusterKeyRateLimitCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 构建redis限流key和参数
|
// 构建redis限流key和参数
|
||||||
limitKey := fmt.Sprintf(ClusterRateLimitFormat, config.ruleName, ruleItem.limitType, ruleItem.key, val)
|
limitKey := fmt.Sprintf(ClusterRateLimitFormat, config.ruleName, ruleItem.limitType, configItem.timeWindow, configItem.count, ruleItem.key, val)
|
||||||
keys := []interface{}{limitKey}
|
keys := []interface{}{limitKey}
|
||||||
args := []interface{}{configItem.count, configItem.timeWindow}
|
args := []interface{}{configItem.count, configItem.timeWindow}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user