set.go 941 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. }