fix
This commit is contained in:
28
app/storage/redis/locks.go
Normal file
28
app/storage/redis/locks.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"queues-go/app/utils"
|
||||
|
||||
"github.com/go-redsync/redsync/v4"
|
||||
"github.com/go-redsync/redsync/v4/redis/goredis/v9"
|
||||
goredislib "github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var Sync redsync.Redsync
|
||||
|
||||
func Connect() {
|
||||
client := goredislib.NewClient(getOptions())
|
||||
pool := goredis.NewPool(client)
|
||||
Sync = *redsync.New(pool)
|
||||
}
|
||||
|
||||
func getOptions() *goredislib.Options {
|
||||
addr := fmt.Sprintf("%s:6379", utils.GetEnv("REDIS_HOST", "localhost"))
|
||||
password := utils.GetEnv("REDIS_PASSWORD", "password")
|
||||
|
||||
return &goredislib.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user