Example #1
0
func (d *sentinelDB) Cmd(cmd string, args ...interface{}) *redis.Resp {
	sentinel, conn, err := d.getSentinelAndMaster()
	if err != nil {
		return redis.NewResp(err)
	}
	defer sentinel.PutMaster(config.RedisSentinelGroup, conn)

	return conn.Cmd(cmd, args...)
}
Example #2
0
func (d sentinelDB) GetAddr() (string, error) {
	sentinel, c, err := d.getSentinelAndMaster()
	if err != nil {
		return "", err
	}
	defer sentinel.PutMaster(config.RedisSentinelGroup, c)

	return c.Addr, nil
}
Example #3
0
func (d sentinelDB) Lua(cmd string, numKeys int, args ...interface{}) *redis.Resp {
	sentinel, c, err := d.getSentinelAndMaster()
	if err != nil {
		return redis.NewResp(err)
	}
	defer sentinel.PutMaster(config.RedisSentinelGroup, c)

	r := luaHelper(c, cmd, numKeys, args...)
	return r
}
Example #4
0
func (d sentinelDB) Scan(pattern string) <-chan string {
	retCh := make(chan string)
	go func() {
		defer close(retCh)

		sentinel, redisClient, err := d.getSentinelAndMaster()
		if err != nil {
			log.L.Printf("sentinelScan(%s) getSentinelAndMaster(): %s", pattern, err)
			return
		}
		defer sentinel.PutMaster(config.RedisSentinelGroup, redisClient)

		if err = scanHelper(redisClient, pattern, retCh); err != nil {
			log.L.Printf("sentinelScan(%s) scanHelper: %s", pattern, err)
			return
		}
	}()

	return retCh
}
Example #5
0
func (d sentinelDB) Pipe(p ...*PipePart) ([]*redis.Resp, error) {
	sentinel, c, err := d.getSentinelAndMaster()
	if err != nil {
		return nil, err
	}
	defer sentinel.PutMaster(config.RedisSentinelGroup, c)

	for i := range p {
		c.PipeAppend(p[i].cmd, p[i].args...)
	}

	rs := make([]*redis.Resp, len(p))
	for i := range rs {
		rs[i] = c.PipeResp()
		if err = rs[i].Err; err != nil {
			return nil, err
		}
	}

	return rs, nil
}