mirror of
https://github.com/alibaba/higress.git
synced 2026-05-08 04:17:27 +08:00
feat: add replay protection plugin (#1672)
Co-authored-by: hanxiantao <601803023@qq.com>
This commit is contained in:
@@ -44,6 +44,7 @@ type RedisClient interface {
|
||||
Get(key string, callback RedisResponseCallback) error
|
||||
Set(key string, value interface{}, callback RedisResponseCallback) error
|
||||
SetEx(key string, value interface{}, ttl int, callback RedisResponseCallback) error
|
||||
SetNX(key string, value interface{}, ttl int, callback RedisResponseCallback) error
|
||||
MGet(keys []string, callback RedisResponseCallback) error
|
||||
MSet(kvMap map[string]interface{}, callback RedisResponseCallback) error
|
||||
Incr(key string, callback RedisResponseCallback) error
|
||||
@@ -308,6 +309,22 @@ func (c *RedisClusterClient[C]) SetEx(key string, value interface{}, ttl int, ca
|
||||
return RedisCall(c.cluster, respString(args), callback)
|
||||
}
|
||||
|
||||
func (c *RedisClusterClient[C]) SetNX(key string, value interface{}, ttl int, callback RedisResponseCallback) error {
|
||||
if err := c.checkReadyFunc(); err != nil {
|
||||
return err
|
||||
}
|
||||
args := make([]interface{}, 0)
|
||||
args = append(args, "set")
|
||||
args = append(args, key)
|
||||
args = append(args, value)
|
||||
args = append(args, "nx")
|
||||
if ttl > 0 {
|
||||
args = append(args, "ex")
|
||||
args = append(args, ttl)
|
||||
}
|
||||
return RedisCall(c.cluster, respString(args), callback)
|
||||
}
|
||||
|
||||
func (c *RedisClusterClient[C]) MGet(keys []string, callback RedisResponseCallback) error {
|
||||
if err := c.checkReadyFunc(); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user