lock.go 683 字节
package redis

import (
	"fmt"
	"github.com/zeromicro/go-zero/core/stores/redis"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)

func KeyExportTable(ctx *domain.Context, tableId int) string {
	return fmt.Sprintf("%v:lock-table:%v:%v", constant.CACHE_PREFIX, tableId, ctx.OperatorId)
}

var ZeroCoreRedis *redis.Redis

func InitZeroCoreRedis() {
	ZeroCoreRedis = redis.New(constant.REDIS_HOST+":"+constant.REDIS_PORT, redis.WithPass(constant.REDIS_AUTH))
}

func NewLock(key string) *redis.RedisLock {
	return redis.NewRedisLock(ZeroCoreRedis, key)
}