init repo
This commit is contained in:
33
internal/storage/cache/engine.go
vendored
Normal file
33
internal/storage/cache/engine.go
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gitea.com/bitwsd/document_ai/config"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var RedisClient *redis.Client
|
||||
|
||||
func InitRedisClient(config config.RedisConfig) {
|
||||
fmt.Println("Initializing Redis client...")
|
||||
RedisClient = redis.NewClient(&redis.Options{
|
||||
Addr: config.Addr,
|
||||
Password: config.Password,
|
||||
DB: config.DB,
|
||||
DialTimeout: 10 * time.Second,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
})
|
||||
|
||||
fmt.Println("Pinging Redis server...")
|
||||
_, err := RedisClient.Ping(context.Background()).Result()
|
||||
if err != nil {
|
||||
fmt.Printf("Init redis client failed, err: %v\n", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("Redis client initialized successfully.")
|
||||
}
|
||||
Reference in New Issue
Block a user