File: cluster_go17.go

package info (click to toggle)
golang-github-mna-redisc 1.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 308 kB
  • sloc: ruby: 1,261; sh: 101; makefile: 5
file content (23 lines) | stat: -rw-r--r-- 424 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// +build go1.7

package redisc

import (
	"context"

	"github.com/gomodule/redigo/redis"
)

// get connection from the pool.
// use GetContext if PoolWaitTime > 0
func (c *Cluster) getFromPool(p *redis.Pool) (redis.Conn, error) {
	if c.PoolWaitTime <= 0 {
		conn := p.Get()
		return conn, conn.Err()
	}

	ctx, cancel := context.WithTimeout(context.Background(), c.PoolWaitTime)
	defer cancel()

	return p.GetContext(ctx)
}