redis_lock.go 491 字节
package xredis

import (
	"fmt"

	"github.com/go-redsync/redsync/v4"
)

type LockSummaryEvaluation struct {
	m *redsync.Mutex
}

func NewLockSummaryEvaluation(targetUserId int) *LockSummaryEvaluation {
	key := fmt.Sprintf("performance:summary_evaluation:%d", targetUserId)

	return &LockSummaryEvaluation{
		m: rsync.NewMutex(key),
	}
}

func (lk *LockSummaryEvaluation) Lock() error {
	return lk.m.Lock()
}

func (lk *LockSummaryEvaluation) UnLock() (bool, error) {
	return lk.m.Unlock()
}