25 lines
461 B
Go
25 lines
461 B
Go
|
package redis
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"time"
|
||
|
|
||
|
"git.loafle.net/commons_go/config"
|
||
|
"git.loafle.net/commons_go/logging"
|
||
|
rp "git.loafle.net/commons_go/redis_pool"
|
||
|
)
|
||
|
|
||
|
func NewPool(ctx context.Context) rp.Pool {
|
||
|
h := &poolHandlers{
|
||
|
ctx: ctx,
|
||
|
logger: logging.WithContext(ctx),
|
||
|
}
|
||
|
h.cfg = config.Sub("redis")
|
||
|
h.MaxIdle = h.cfg.GetInt("pool.MaxIdle")
|
||
|
h.IdleTimeout = h.cfg.GetDuration("pool.IdleTimeout") * time.Second
|
||
|
|
||
|
p := rp.NewPool(ctx, h)
|
||
|
|
||
|
return p
|
||
|
}
|