wip11
This commit is contained in:
Vendored
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* Copyright (c) 2025-2026, Антон Аксенов
|
||||
* This file is part of iptvc project
|
||||
* MIT License: https://git.axenov.dev/IPTV/iptvc/src/branch/master/LICENSE
|
||||
*/
|
||||
@@ -17,23 +17,23 @@ import (
|
||||
)
|
||||
|
||||
func Init(cfg *config.CacheConfig) *redis.Client {
|
||||
redisUrl := fmt.Sprintf("%s:%s", cfg.Host, strconv.Itoa(int(cfg.Port)))
|
||||
redisClient := redis.NewClient(&redis.Options{
|
||||
Addr: redisUrl,
|
||||
cacheAddr := fmt.Sprintf("%s:%s", cfg.Host, strconv.Itoa(int(cfg.Port)))
|
||||
cacheClient := redis.NewClient(&redis.Options{
|
||||
Addr: cacheAddr,
|
||||
DB: int(cfg.Db),
|
||||
PoolSize: 1000,
|
||||
ReadTimeout: -1,
|
||||
WriteTimeout: -1,
|
||||
})
|
||||
client := redisClient.Conn()
|
||||
client := cacheClient.Conn()
|
||||
ctx := context.Background()
|
||||
err := client.Ping(ctx).Err()
|
||||
if err == nil {
|
||||
log.Println("Connected to cache DB:", redisUrl)
|
||||
log.Println("Connected to cache DB:", cacheAddr)
|
||||
cfg.IsActive = true
|
||||
} else {
|
||||
log.Println("Error while connecting to cache DB, program may work not as expected:", err)
|
||||
}
|
||||
|
||||
return redisClient
|
||||
return cacheClient
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user