Add Redis initialization to main function

This commit is contained in:
2024-09-08 17:25:17 +07:00
parent 595112b9cf
commit 66b1162c53
3 changed files with 54 additions and 13 deletions

7
cache/cache.go vendored
View File

@ -2,6 +2,7 @@ package cache
import (
"context"
"fmt"
"github.com/fossyy/filekeeper/types"
"github.com/redis/go-redis/v9"
"time"
@ -12,10 +13,10 @@ type RedisServer struct {
database types.Database
}
func NewRedisServer(db types.Database) types.CachingServer {
func NewRedisServer(host, port, password string, db types.Database) types.CachingServer {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "Password123",
Addr: fmt.Sprintf("%s:%s", host, port),
Password: password,
DB: 0,
})
return &RedisServer{client: client, database: db}