pubsub.go 437 B

123456789101112131415161718
  1. package cache
  2. import "github.com/go-redis/redis"
  3. func (p *RedisCache) Publish(channel string, message interface{}) (int64, error) {
  4. if p.isCluster {
  5. return p.cluster.Publish(channel, message).Result()
  6. }
  7. return p.client.Publish(channel, message).Result()
  8. }
  9. func (p *RedisCache) Subscribe(channels ...string) *redis.PubSub {
  10. if p.isCluster {
  11. return p.cluster.Subscribe(channels...)
  12. }
  13. return p.client.Subscribe(channels...)
  14. }