Initial commit
All checks were successful
release / release (push) Successful in 5m47s

This commit is contained in:
2025-05-01 00:46:24 +08:00
commit d15d4f47b6
22 changed files with 1556 additions and 0 deletions

36
app/cache/cache.go vendored Normal file
View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2025, Антон Аксенов
* This file is part of iptvc project
* MIT License: https://git.axenov.dev/IPTV/iptvc/src/branch/master/LICENSE
*/
package cache
import (
"axenov/iptv-checker/app/config"
"context"
"fmt"
"github.com/redis/go-redis/v9"
"log"
"strconv"
)
func Init(cfg config.RedisConfig) *redis.Client {
rdb := redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%s", cfg.Host, strconv.Itoa(int(cfg.Port))),
DB: int(cfg.Db),
PoolSize: 1000,
ReadTimeout: -1,
WriteTimeout: -1,
})
client := rdb.Conn()
var ctx context.Context
if client.Ping(ctx).Err() != nil {
log.Println("Error while connecting to Redis", cfg.Host, cfg.Port, cfg.Db)
} else {
log.Println("Connected to Redis", cfg.Host, cfg.Port, cfg.Db)
}
return rdb
}