Search in sources :

Example 1 with DefaultClientResources

use of com.lambdaworks.redis.resource.DefaultClientResources in project x-pipe by ctripcorp.

the class RedisSessionTest method createRedisClient.

private RedisClient createRedisClient(String host, int port) {
    RedisURI redisUri = new RedisURI(host, port, 2, TimeUnit.SECONDS);
    SocketOptions socketOptions = SocketOptions.builder().connectTimeout(XPipeConsoleConstant.SOCKET_TIMEOUT, TimeUnit.SECONDS).build();
    ClientOptions clientOptions = // 
    ClientOptions.builder().socketOptions(socketOptions).disconnectedBehavior(// 
    ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build();
    DefaultClientResources clientResources = // 
    DefaultClientResources.builder().reconnectDelay(// 
    Delay.constant(1, TimeUnit.SECONDS)).build();
    RedisClient redis = RedisClient.create(clientResources, redisUri);
    redis.setOptions(clientOptions);
    return redis;
}
Also used : RedisClient(com.lambdaworks.redis.RedisClient) ClientOptions(com.lambdaworks.redis.ClientOptions) RedisURI(com.lambdaworks.redis.RedisURI) SocketOptions(com.lambdaworks.redis.SocketOptions) DefaultClientResources(com.lambdaworks.redis.resource.DefaultClientResources)

Aggregations

ClientOptions (com.lambdaworks.redis.ClientOptions)1 RedisClient (com.lambdaworks.redis.RedisClient)1 RedisURI (com.lambdaworks.redis.RedisURI)1 SocketOptions (com.lambdaworks.redis.SocketOptions)1 DefaultClientResources (com.lambdaworks.redis.resource.DefaultClientResources)1