コード例 #1
0
ファイル: simpleredis.go プロジェクト: trietphm/simpleredis
// Get one of the available connections from the connection pool, given a database index
func (pool *ConnectionPool) Get(dbindex int) redis.Conn {
	redisPool := redis.Pool(*pool)
	conn := redisPool.Get()
	// The default database index is 0
	if dbindex != 0 {
		// SELECT is not critical, ignore the return values
		conn.Do("SELECT", strconv.Itoa(dbindex))
	}
	return conn
}
コード例 #2
0
ファイル: simpleredis.go プロジェクト: trietphm/simpleredis
// Close down the connection pool
func (pool *ConnectionPool) Close() {
	redisPool := redis.Pool(*pool)
	redisPool.Close()
}
コード例 #3
0
ファイル: simpleredis.go プロジェクト: trietphm/simpleredis
// Ping the server by sending a PING command
func (pool *ConnectionPool) Ping() error {
	redisPool := redis.Pool(*pool)
	conn := redisPool.Get()
	_, err := conn.Do("PING")
	return err
}
コード例 #4
0
ファイル: simpleredis.go プロジェクト: 40a/bootkube
// Ping the server by sending a PING command
func (pool *ConnectionPool) Ping() (pong bool) {
	redisPool := redis.Pool(*pool)
	conn := redisPool.Get()
	_, err := conn.Do("PING")
	return err == nil
}