33 lines
681 B
Go
33 lines
681 B
Go
package redisutils
|
|
|
|
import (
|
|
re "github.com/fiskerinc/cloud-services/pkg/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
|
|
}
|