com.lambdaworks.redis.api.StatefulRedisConnection Java Examples

The following examples show how to use com.lambdaworks.redis.api.StatefulRedisConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LettuceRedisClient.java    From SampleCode with MIT License 6 votes vote down vote up
protected StatefulRedisConnection<String, String> getConnection()
{
    if (connection == null) {
        synchronized (syncObject)
        {
            if (connection == null)
            {
                Logging.write("$");
                RedisClient client = getRedisClient();
                connection = client.connect();
                TrySetClientName();
            }
        }
    }

    return connection;
}
 
Example #2
Source File: FutureSyncInvocationHandler.java    From spinach with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {

    try {

        Method targetMethod = methodCache.get(method);
        Object result = targetMethod.invoke(asyncApi, args);

        if (result instanceof RedisFuture) {
            RedisFuture<?> command = (RedisFuture<?>) result;
            if (!method.getName().equals("exec") && !method.getName().equals("multi")) {
                if (connection instanceof StatefulRedisConnection && ((StatefulRedisConnection) connection).isMulti()) {
                    return null;
                }
            }

            LettuceFutures.awaitOrCancel(command, connection.getTimeout(), connection.getTimeoutUnit());
            return command.get();
        }
        return result;
    } catch (InvocationTargetException e) {
        throw e.getTargetException();
    }

}
 
Example #3
Source File: RedisAsyncCommanderProvider.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
public RedisAsyncCommanderProvider(String uri){
	RedisClient client = RedisClient.create(uri);
	StatefulRedisConnection<String, byte[]> connect = client.connect(getCodec());
	cmd = connect.async();
}