set.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package cache
  2. import "fmt"
  3. func (p *RedisCache) SCard(key string) (int64, error) {
  4. if p.isCluster {
  5. return p.cluster.SCard(key).Result()
  6. }
  7. return p.client.SCard(key).Result()
  8. }
  9. func (p *RedisCache) SAdd(key string, members ...interface{}) (int64, error) {
  10. if p.isCluster {
  11. return p.cluster.SAdd(key, members...).Result()
  12. }
  13. return p.client.SAdd(key, members...).Result()
  14. }
  15. func (p *RedisCache) SMembers(key string) ([]string, error) {
  16. if p.isCluster {
  17. return p.cluster.SMembers(key).Result()
  18. }
  19. return p.client.SMembers(key).Result()
  20. }
  21. func (p *RedisCache) SIsmember(key string, member interface{}) (bool, error) {
  22. if p.isCluster {
  23. return p.cluster.SIsMember(key, member).Result()
  24. }
  25. return p.client.SIsMember(key, member).Result()
  26. }
  27. func (p *RedisCache) SInter(keys ...string) ([]string, error) {
  28. if p.isCluster {
  29. return nil, fmt.Errorf("cluster unsupport <sinter>.")
  30. }
  31. return p.client.SInter(keys...).Result()
  32. }
  33. func (p *RedisCache) SRem(key string, members ...interface{}) (int64, error) {
  34. if p.isCluster {
  35. return p.cluster.SRem(key, members).Result()
  36. }
  37. return p.client.SRem(key, members).Result()
  38. }