Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRedisIsDown = errors.New("storage: Redis is either down or ws not configured")
当我们无法与redis通信时,会返回errRedisDown。
Functions ¶
func ConnectToRedis ¶
********************* ConnectToRedis启动一个go例程,定期尝试连接到redis(断开时候重连)。 并给redisUp 赋值说明此时redis能够正常连接 首先进行与redis连接初始化 pkg/redis 为其他服务使用做准备
func NewRedisClusterPool ¶
根据 config new Redis 新建RedisClusterPool创建redis集群池
Types ¶
type Config ¶
type Config struct { Host string // 主机 (单机时候 host) Port int // 端口 Addrs []string // 集群的 MasterName string // 主库名 Username string // 用户名 Password string // 密码 Database int // redis那个库 MaxIdle int // 最大空闲时间 MaxActive int // 最大连接数 Timeout int // 超时时间 EnableCluster bool // 启用群集 UseSSL bool // 使用加密 SSLInsecureSkipVerify bool // SSL不安全跳过验证 ?? }
配置定义redis群集的选项。
type RedisCluster ¶
type RedisCluster struct { KeyPrefix string // 密钥前缀 HashKeys bool // hash key IsCache bool // 是否缓存 }
RedisCluster是一个使用redis数据库的存储管理器,外部使用
func (*RedisCluster) Publish ¶
func (r *RedisCluster) Publish(channel, message string) error
往 channel 中发送消息
func (*RedisCluster) StartPubSubHandler ¶
func (r *RedisCluster) StartPubSubHandler(channel string, callback func(interface{})) error
StartSubsubHandler 监听信号并为其运行回调每个订阅和消息事件。
Click to show internal directories.
Click to hide internal directories.