Qo'shildi: Docker konfiguratsiyasi yangilandi, .env va .gitignore fayllari yaratildi, Redis va muhit o'zgaruvchilari qo'shildi.
This commit is contained in:
27
internal/redis/client.go
Normal file
27
internal/redis/client.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var RDB *redis.Client
|
||||
|
||||
func InitRedis() {
|
||||
DB, _ := strconv.Atoi(os.Getenv("REDIS_DB"))
|
||||
RDB = redis.NewClient(&redis.Options{
|
||||
Addr: os.Getenv("REDIS_ADDRESS"),
|
||||
Password: os.Getenv("REDIS_PASSWORD"),
|
||||
DB: DB,
|
||||
})
|
||||
|
||||
// Test connection
|
||||
_, err := RDB.Ping(context.Background()).Result()
|
||||
if err != nil {
|
||||
log.Fatalf("Redisga ulanib bo'lmadi: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user