package hashring import ( "context" "git.zhangshuocauc.cn/redhat/goconsistencehash/redis/lock" "github.com/redis/go-redis/v9" ) type RedisLockWrap struct { client *redis.Client key string lock *lock.RedisLock } func NewRedisLockWrap(client *redis.Client, key string) *RedisLockWrap { return &RedisLockWrap{ client: client, key: key, } } func (r *RedisLockWrap) Lock(ctx context.Context, expire int) error { r.lock = lock.NewRedisLock(r.client, r.key, lock.WithExpireTime(expire)) return r.lock.Lock(ctx) } func (r *RedisLockWrap) UnLock(ctx context.Context) error { return r.lock.UnLock(ctx) }