RedissonWriteLock forceUnlockAsync fixed

pull/337/head
Nikita 9 years ago
parent 615eedd580
commit ee3704356b

@ -26,6 +26,8 @@ import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandExecutor;
import org.redisson.core.RLock;
import io.netty.util.concurrent.Future;
/**
* Lock will be removed automatically if client disconnects.
*
@ -110,6 +112,19 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
throw new UnsupportedOperationException();
}
Future<Boolean> forceUnlockAsync() {
cancelExpirationRenewal();
return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN,
"if (redis.call('hget', KEYS[1], 'mode') == 'write') then " +
"redis.call('del', KEYS[1]); " +
"redis.call('publish', KEYS[2], ARGV[1]); " +
"return 1; " +
"else " +
"return 0; " +
"end;",
Arrays.<Object>asList(getName(), getChannelName()), unlockMessage);
}
@Override
public boolean isLocked() {
String res = commandExecutor.read(getName(), StringCodec.INSTANCE, RedisCommands.HGET, getName(), "mode");

Loading…
Cancel
Save