Search in sources :

Example 1 with ClientOptions

use of com.lambdaworks.redis.ClientOptions 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)

Example 2 with ClientOptions

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

the class DefaultRedisSessionManager method findRedisConnection.

public RedisClient findRedisConnection(String host, int port) {
    RedisURI redisUri = new RedisURI(host, port, 1, TimeUnit.SECONDS);
    SocketOptions socketOptions = SocketOptions.builder().connectTimeout(XPipeConsoleConstant.SOCKET_TIMEOUT, TimeUnit.SECONDS).build();
    ClientOptions clientOptions = // 
    ClientOptions.builder().socketOptions(socketOptions).disconnectedBehavior(// 
    DisconnectedBehavior.REJECT_COMMANDS).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)

Example 3 with ClientOptions

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

the class LuttuceJedisCompareTest method findRedisConnection.

private static RedisClient findRedisConnection(String host, int port) {
    ClientResources clientResources = // 
    DefaultClientResources.builder().reconnectDelay(// 
    Delay.constant(10, TimeUnit.SECONDS)).build();
    RedisURI redisUri = new RedisURI(host, port, 2, TimeUnit.SECONDS);
    ClientOptions clientOptions = // 
    ClientOptions.builder().disconnectedBehavior(// 
    DisconnectedBehavior.REJECT_COMMANDS).build();
    RedisClient redis = RedisClient.create(clientResources, redisUri);
    redis.setOptions(clientOptions);
    return redis;
}
Also used : RedisClient(com.lambdaworks.redis.RedisClient) ClientOptions(com.lambdaworks.redis.ClientOptions) ClientResources(com.lambdaworks.redis.resource.ClientResources) DefaultClientResources(com.lambdaworks.redis.resource.DefaultClientResources) RedisURI(com.lambdaworks.redis.RedisURI)

Aggregations

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