Skip to content

Commit

Permalink
RObject.isExists and RObject.isExistsAsync added. #316
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita committed Dec 8, 2015
1 parent c9dd022 commit 52a0c62
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/org/redisson/RedissonBucket.java
Expand Up @@ -64,14 +64,24 @@ public Future<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETEX, getName(), timeUnit.toSeconds(timeToLive), value);
}

@Override
public boolean exists() {
return get(existsAsync());
/**
* Use {@link #isExistsAsync()}
*
* @return
*/
@Deprecated
public Future<Boolean> existsAsync() {
return isExistsAsync();
}

@Override
public Future<Boolean> existsAsync() {
return commandExecutor.readAsync(getName(), codec, RedisCommands.EXISTS, getName());
/**
* Use {@link #isExists()}
*
* @return
*/
@Deprecated
public boolean exists() {
return isExists();
}

}
10 changes: 10 additions & 0 deletions src/main/java/org/redisson/RedissonObject.java
Expand Up @@ -112,4 +112,14 @@ public Future<Boolean> deleteAsync() {
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());
}

}
6 changes: 6 additions & 0 deletions src/main/java/org/redisson/core/RBucket.java
Expand Up @@ -32,6 +32,12 @@ public interface RBucket<V> extends RExpirable, RBucketAsync<V> {

void set(V value, long timeToLive, TimeUnit timeUnit);

/**
* Use {@link #isExists()}
*
* @return
*/
@Deprecated
boolean exists();

}
6 changes: 6 additions & 0 deletions src/main/java/org/redisson/core/RBucketAsync.java
Expand Up @@ -34,6 +34,12 @@ public interface RBucketAsync<V> extends RExpirableAsync {

Future<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit);

/**
* Use {@link #isExistsAsync()}
*
* @return
*/
@Deprecated
Future<Boolean> existsAsync();

}
7 changes: 7 additions & 0 deletions src/main/java/org/redisson/core/RObject.java
Expand Up @@ -69,4 +69,11 @@ public interface RObject extends RObjectAsync {
*/
boolean renamenx(String newName);

/**
* Check object existence
*
* @return <code>true</code> if object exists and <code>false</code> otherwise
*/
boolean isExists();

}
7 changes: 7 additions & 0 deletions src/main/java/org/redisson/core/RObjectAsync.java
Expand Up @@ -69,4 +69,11 @@ public interface RObjectAsync {
*/
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();

}

0 comments on commit 52a0c62

Please sign in to comment.