This commit is contained in:
2026-03-23 18:55:27 +07:00
parent 6dc0322fe5
commit 3626c12319
47 changed files with 2741 additions and 0 deletions

32
pkg/cache/redis.go vendored Normal file
View File

@@ -0,0 +1,32 @@
package cache
import (
"context"
"fmt"
"history-api/pkg/config"
"github.com/redis/go-redis/v9"
)
var RI *redis.Client
func Connect() error {
connectionURI, err := config.GetConfig("REDIS_CONNECTION_URI")
if err != nil {
return err
}
rdb := redis.NewClient(&redis.Options{
Addr: connectionURI,
Password: "",
DB: 0,
})
if err := rdb.Ping(context.Background()).Err(); err != nil {
return fmt.Errorf("Could not connect to Redis: %v", err)
}
RI = rdb
return nil
}