Переворошил файлы (опять), закинул всё в докер

This commit is contained in:
B4D_US3R 2025-04-21 23:13:46 +05:00
parent be76c08756
commit c853cfb592
11 changed files with 135 additions and 54 deletions

43
stacker/stacker.go Normal file
View file

@ -0,0 +1,43 @@
package stacker
import (
"context"
"github.com/redis/go-redis/v9"
)
func ConnectToRedis(addr string) redis.Client {
rdb := redis.NewClient(&redis.Options{
Addr: addr,
Password: "",
DB: 0,
})
return *rdb
}
func SetToRedis(rdb redis.Client, key string, val interface{}) error {
err := rdb.Set(context.Background(), key, val, 0).Err()
if err != nil {
return err
}
return nil
}
func CheckInRedis(rdb redis.Client, key string) (bool, error) {
_, err := rdb.Get(context.Background(), key).Result()
if err == redis.Nil {
return false, nil
} else if err != nil {
return false, err
}
return true, nil
}
func SaveRedis(rdb redis.Client) error {
err := rdb.Save(context.Background()).Err()
if err != nil {
return err
}
return nil
}