Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
32
pkg/redis/redisutils/check_set.go
Normal file
32
pkg/redis/redisutils/check_set.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package redisutils
|
||||
|
||||
import (
|
||||
re "fiskerinc.com/modules/redis"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func CheckSet(conn re.Client, id string, keys interface{}) ([]bool, error) {
|
||||
ckeys, ok := keys.([]string)
|
||||
if !ok {
|
||||
return nil, errors.New("keys is not []string")
|
||||
}
|
||||
|
||||
results := make([]bool, len(ckeys))
|
||||
batch := re.NewRedisBatchCommands()
|
||||
|
||||
for _, key := range ckeys {
|
||||
batch.Add("SISMEMBER", id, key)
|
||||
}
|
||||
|
||||
values, err := conn.ExecuteBatch(batch)
|
||||
if err != nil {
|
||||
return results, err
|
||||
}
|
||||
|
||||
err = redis.ScanSlice(values.([]interface{}), &results)
|
||||
if err != nil {
|
||||
return results, errors.WithStack(err)
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
Reference in New Issue
Block a user