/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.platform.components;

import com.crunii.micro.component.redis.lock.DistributeLock;
import org.redisson.api.RedissonClient;

/**
 * @author 田平 create 2021/9/2 17:05
 */
public class LockerImpl implements Locker {

	private DistributeLock distributeLock;

	public LockerImpl(RedissonClient redissonClient) {
		this.distributeLock = new DistributeLock(redissonClient);
	}

	@Override
	public void lock(String namespace, String lockId) {
		distributeLock.lock(namespace + ":" + lockId);
	}

	@Override
	public void lock(String namespace, String lockId, int expiredTime) {
		distributeLock.lock(namespace + ":" + lockId, expiredTime);
	}

	@Override
	public void unlock() {
		distributeLock.unlock();
	}
}
