fixed bug for redis pool connection timeout

This commit is contained in:
RockYang
2025-02-21 15:19:58 +08:00
parent c39dd913fd
commit 63fd125439
10 changed files with 54 additions and 184 deletions

View File

@@ -10,14 +10,18 @@ package store
import (
"context"
"geekai/core/types"
"time"
"github.com/go-redis/redis/v8"
)
func NewRedisClient(config *types.AppConfig) (*redis.Client, error) {
client := redis.NewClient(&redis.Options{
Addr: config.Redis.Url(),
Password: config.Redis.Password,
DB: config.Redis.DB,
Addr: config.Redis.Url(),
Password: config.Redis.Password,
DB: config.Redis.DB,
PoolSize: 20,
PoolTimeout: 5 * time.Second,
})
_, err := client.Ping(context.Background()).Result()
if err != nil {