印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
710 B

package redis
import (
"context"
"server/common"
"github.com/liangdas/mqant/log"
)
// 投放机器人
func (u *RedisClient) UseRobot(id int) bool {
ok, err := u.GetRedis().SetNX(context.Background(), common.GetRedisKeyRobotPlaying(id), 1, 0).Result()
if err != nil {
log.Error("err:%v", err)
return false
}
if !ok {
return false
}
if _, err := u.Incr(common.GetRedisKeyRobotPlaying(0), 1); err != nil {
log.Error("err:%v", err)
}
return true
}
// 回收机器人
func (u *RedisClient) DelRobot(id int) {
count := u.Delkey(common.GetRedisKeyRobotPlaying(id))
if count > 0 {
if _, err := u.Incr(common.GetRedisKeyRobotPlaying(0), -1); err != nil {
log.Error("err:%v", err)
}
}
}