mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 08:46:38 +08:00
28 lines
756 B
Go
28 lines
756 B
Go
package store
|
|
|
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
|
// * Use of this source code is governed by a Apache-2.0 license
|
|
// * that can be found in the LICENSE file.
|
|
// * @Author yangjian102621@163.com
|
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
import (
|
|
"context"
|
|
"geekai/core/types"
|
|
"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,
|
|
})
|
|
_, err := client.Ping(context.Background()).Result()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return client, nil
|
|
}
|