RObject.isExists and RObject.isExistsAsync added. #316

pull/337/head
Nikita 9 years ago
parent c9dd0229f1
commit 52a0c62477

@ -64,14 +64,24 @@ public class RedissonBucket<V> extends RedissonExpirable implements RBucket<V> {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETEX, getName(), timeUnit.toSeconds(timeToLive), value); return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETEX, getName(), timeUnit.toSeconds(timeToLive), value);
} }
@Override /**
public boolean exists() { * Use {@link #isExistsAsync()}
return get(existsAsync()); *
* @return
*/
@Deprecated
public Future<Boolean> existsAsync() {
return isExistsAsync();
} }
@Override /**
public Future<Boolean> existsAsync() { * Use {@link #isExists()}
return commandExecutor.readAsync(getName(), codec, RedisCommands.EXISTS, getName()); *
* @return
*/
@Deprecated
public boolean exists() {
return isExists();
} }
} }

@ -112,4 +112,14 @@ abstract class RedissonObject implements RObject {
return commandExecutor.writeAsync(getName(), RedisCommands.DEL_SINGLE, getName()); return commandExecutor.writeAsync(getName(), RedisCommands.DEL_SINGLE, getName());
} }
@Override
public boolean isExists() {
return get(isExistsAsync());
}
@Override
public Future<Boolean> isExistsAsync() {
return commandExecutor.readAsync(getName(), codec, RedisCommands.EXISTS, getName());
}
} }

@ -32,6 +32,12 @@ public interface RBucket<V> extends RExpirable, RBucketAsync<V> {
void set(V value, long timeToLive, TimeUnit timeUnit); void set(V value, long timeToLive, TimeUnit timeUnit);
/**
* Use {@link #isExists()}
*
* @return
*/
@Deprecated
boolean exists(); boolean exists();
} }

@ -34,6 +34,12 @@ public interface RBucketAsync<V> extends RExpirableAsync {
Future<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit); Future<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit);
/**
* Use {@link #isExistsAsync()}
*
* @return
*/
@Deprecated
Future<Boolean> existsAsync(); Future<Boolean> existsAsync();
} }

@ -69,4 +69,11 @@ public interface RObject extends RObjectAsync {
*/ */
boolean renamenx(String newName); boolean renamenx(String newName);
/**
* Check object existence
*
* @return <code>true</code> if object exists and <code>false</code> otherwise
*/
boolean isExists();
} }

@ -69,4 +69,11 @@ public interface RObjectAsync {
*/ */
Future<Boolean> renamenxAsync(String newName); Future<Boolean> renamenxAsync(String newName);
/**
* Check object existence in async mode.
*
* @return <code>true</code> if object exists and <code>false</code> otherwise
*/
Future<Boolean> isExistsAsync();
} }

Loading…
Cancel
Save