Search in sources :

Example 1 with TouchOperation

use of org.redisson.transaction.operation.TouchOperation in project redisson by redisson.

the class BaseTransactionalMap method touchAsync.

public RFuture<Boolean> touchAsync(CommandAsyncExecutor commandExecutor) {
    RPromise<Boolean> result = new RedissonPromise<Boolean>();
    if (deleted != null && deleted) {
        operations.add(new TouchOperation(map.getName()));
        result.trySuccess(false);
        return result;
    }
    map.isExistsAsync().onComplete((exists, e) -> {
        if (e != null) {
            result.tryFailure(e);
            return;
        }
        operations.add(new TouchOperation(map.getName()));
        if (!exists) {
            for (MapEntry entry : state.values()) {
                if (entry != MapEntry.NULL) {
                    exists = true;
                    break;
                }
            }
        }
        result.trySuccess(exists);
    });
    return result;
}
Also used : RedissonPromise(org.redisson.misc.RedissonPromise) TouchOperation(org.redisson.transaction.operation.TouchOperation)

Example 2 with TouchOperation

use of org.redisson.transaction.operation.TouchOperation in project redisson by redisson.

the class BaseTransactionalSet method touchAsync.

public RFuture<Boolean> touchAsync(CommandAsyncExecutor commandExecutor) {
    RPromise<Boolean> result = new RedissonPromise<Boolean>();
    if (deleted != null && deleted) {
        operations.add(new TouchOperation(name));
        result.trySuccess(false);
        return result;
    }
    set.isExistsAsync().onComplete((exists, e) -> {
        if (e != null) {
            result.tryFailure(e);
            return;
        }
        operations.add(new TouchOperation(name));
        if (!exists) {
            for (Object value : state.values()) {
                if (value != NULL) {
                    exists = true;
                    break;
                }
            }
        }
        result.trySuccess(exists);
    });
    return result;
}
Also used : RedissonPromise(org.redisson.misc.RedissonPromise) TouchOperation(org.redisson.transaction.operation.TouchOperation) RedissonObject(org.redisson.RedissonObject)

Aggregations

RedissonPromise (org.redisson.misc.RedissonPromise)2 TouchOperation (org.redisson.transaction.operation.TouchOperation)2 RedissonObject (org.redisson.RedissonObject)1