samba/util/model/playGame.go

30 lines
573 B
Go
Raw Permalink Normal View History

2025-06-04 09:51:39 +08:00
package model
import (
"context"
"fmt"
"github.com/go-redis/redis/v8"
"samba/pkg/log"
"samba/pkg/xtime"
"samba/util/rdbkey"
)
type PlayGameOp struct {
rdb *redis.Client
}
func NewPlayGameOp() *PlayGameOp {
return &PlayGameOp{rdb: rdbGameLog}
}
func (op *PlayGameOp) Update() {
err := op.rdb.Set(context.TODO(), rdbkey.PlayGameKey(), xtime.Now().Timestamp(), 0).Err()
if err != nil {
log.Error(fmt.Sprintf("update playGame faild:%s", err))
}
}
func (op *PlayGameOp) Get() (int64, error) {
return op.rdb.Get(context.TODO(), rdbkey.PlayGameKey()).Int64()
}