samba/util/model/currentService.go

25 lines
523 B
Go
Raw Permalink Normal View History

2025-06-04 09:51:39 +08:00
package model
import (
"context"
"errors"
"github.com/go-redis/redis/v8"
"samba/pkg/log"
"samba/util/rdbkey"
)
func SetCurrentService(gameServers string) {
if err := rdbConfig.Set(context.Background(), rdbkey.ServiceKey(), gameServers, 0).Err(); err != nil {
log.Error(err.Error())
}
}
func GetCurrentService() string {
if ret, err := rdbConfig.Get(context.Background(), rdbkey.ServiceKey()).Result(); err != nil && !errors.Is(err, redis.Nil) {
log.Error(err.Error())
return ""
} else {
return ret
}
}