package cn.wise.sc.acquisition.business.config.lock;

import org.redisson.api.RLock;

import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;

public interface DistributedLocker {

	RLock lock(String lockKey);

	RLock lock(String lockKey, int timeout);

	RLock lock(String lockKey, TimeUnit unit, int timeout);

	boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime);

	void unlock(String lockKey);

	void unlock(RLock lock);

	<T> T executeLock(String key, Function<String, T> consumer, String t);

	<T> void executeLock(String lockKey, Consumer<T> consumer, T t);
}