25 lines
523 B
Go
25 lines
523 B
Go
![]() |
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
|
||
|
}
|
||
|
}
|