feat: add getset command in redis and kv (#1693)

This commit is contained in:
benqi
2022-03-23 18:02:56 +08:00
committed by GitHub
parent c1d9e6a00b
commit bbac994c8a
4 changed files with 80 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ type (
Setex(key, value string, seconds int) error
Setnx(key, value string) (bool, error)
SetnxEx(key, value string, seconds int) (bool, error)
Getset(key, value string) (string, error)
Sismember(key string, value interface{}) (bool, error)
Smembers(key string) ([]string, error)
Spop(key string) (string, error)
@@ -459,6 +460,15 @@ func (cs clusterStore) SetnxEx(key, value string, seconds int) (bool, error) {
return node.SetnxEx(key, value, seconds)
}
func (cs clusterStore) Getset(key, value string) (string, error) {
node, err := cs.getRedis(key)
if err != nil {
return "", err
}
return node.GetSet(key, value)
}
func (cs clusterStore) Sismember(key string, value interface{}) (bool, error) {
node, err := cs.getRedis(key)
if err != nil {