redis_lock.go
471 字节
package xredis
import (
"fmt"
"github.com/go-redsync/redsync/v4"
)
type LockSummaryEvaluation struct {
m *redsync.Mutex
}
func NewLockSummaryEvaluation(id int) *LockSummaryEvaluation {
key := fmt.Sprintf("performance:summary_evaluation:%d", id)
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()
}