mirror of
https://github.com/alibaba/higress.git
synced 2026-03-17 08:50:46 +08:00
improve the logic for constructing redis key (#1933)
This commit is contained in:
@@ -39,7 +39,7 @@ func main() {
|
||||
}
|
||||
|
||||
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 = `
|
||||
local ttl = redis.call('ttl', KEYS[1])
|
||||
if ttl < 0 then
|
||||
@@ -103,7 +103,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config ClusterKeyRateLimitCon
|
||||
}
|
||||
|
||||
// 构建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}
|
||||
args := []interface{}{configItem.count, configItem.timeWindow}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user