Skip to content

Commit

Permalink
INTRENAL: Refactor asyncCollectionExist api.
Browse files Browse the repository at this point in the history
  • Loading branch information
brido4125 committed Aug 23, 2023
1 parent a7ed5e2 commit 5953f6c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,13 @@ public void addResult() {
public <T> CollectionFuture<Boolean> asyncSopExist(String key, T value,
Transcoder<T> tc) {
SetExist<T> exist = new SetExist<T>(value, tc);
return asyncCollectionExist(key, "", exist, tc);
return asyncCollectionExist(key, "", exist);
}

@Override
public CollectionFuture<Boolean> asyncSopExist(String key, Object value) {
SetExist<Object> exist = new SetExist<Object>(value, collectionTranscoder);
return asyncCollectionExist(key, "", exist, collectionTranscoder);
return asyncCollectionExist(key, "", exist);
}

/**
Expand Down Expand Up @@ -961,12 +961,10 @@ public void complete() {
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param collectionExist operation parameters (element value and so on)
* @param tc transcoder to serialize and unserialize value
* @return future holding the success/failure of the operation
*/
private <T> CollectionFuture<Boolean> asyncCollectionExist(
final String key, final String subkey,
final CollectionExist collectionExist, Transcoder<T> tc) {
private <T> CollectionFuture<Boolean> asyncCollectionExist(final String key, final String subkey,
final CollectionExist collectionExist) {
final CountDownLatch latch = new CountDownLatch(1);
final CollectionFuture<Boolean> rv = new CollectionFuture<Boolean>(
latch, operationTimeout);
Expand All @@ -981,8 +979,7 @@ public void receivedStatus(OperationStatus status) {
getLogger().warn("Unhandled state: " + status);
cstatus = new CollectionOperationStatus(status);
}
boolean isExist = (CollectionResponse.EXIST == cstatus.getResponse())
? true : false;
boolean isExist = CollectionResponse.EXIST == cstatus.getResponse();
rv.set(isExist, cstatus);
if (!cstatus.isSuccess()) {
getLogger().debug("Exist command to the collection failed : %s (type=%s, key=%s, subkey=%s)",
Expand Down

0 comments on commit 5953f6c

Please sign in to comment.