/** * Creates a {@link LettuceSentinelConnection} using a {@link LettuceConnectionProvider}. * * @param connectionProvider must not be {@literal null}. * @since 2.0 */ public LettuceSentinelConnection(LettuceConnectionProvider connectionProvider) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.provider = connectionProvider; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied {@link RedisClient}. * * @param redisClient must not be {@literal null}. */ public LettuceSentinelConnection(RedisClient redisClient) { Assert.notNull(redisClient, "Cannot create LettuceSentinelConnection using 'null' as client."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(redisClient.connectSentinel()); } @Override public <T extends StatefulConnection<?, ?>> CompletableFuture<T> getConnectionAsync(Class<T> t) { return CompletableFuture.completedFuture(t.cast(connection)); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied redis connection. * * @param connection native Lettuce connection, must not be {@literal null} */ protected LettuceSentinelConnection(StatefulRedisSentinelConnection<String, String> connection) { Assert.notNull(connection, "Cannot create LettuceSentinelConnection using 'null' as connection."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(connection); } @Override public <T extends StatefulConnection<?, ?>> CompletableFuture<T> getConnectionAsync(Class<T> t) { return CompletableFuture.completedFuture(t.cast(connection)); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port} and reuse * existing {@link ClientResources}. * * @param host must not be {@literal null}. * @param port sentinel port. * @param clientResources must not be {@literal null}. */ public LettuceSentinelConnection(String host, int port, ClientResources clientResources) { Assert.notNull(clientResources, "Cannot create LettuceSentinelConnection using 'null' as ClientResources."); Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port, clientResources); init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port}. * * @param host must not be {@literal null}. * @param port sentinel port. */ public LettuceSentinelConnection(String host, int port) { Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port); init(); }
/** * Creates a {@link LettuceSentinelConnection} using a {@link LettuceConnectionProvider}. * * @param connectionProvider must not be {@literal null}. * @since 2.0 */ public LettuceSentinelConnection(LettuceConnectionProvider connectionProvider) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.provider = connectionProvider; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a {@link LettuceConnectionProvider}. * * @param connectionProvider must not be {@literal null}. * @since 2.0 */ public LettuceSentinelConnection(LettuceConnectionProvider connectionProvider) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.provider = connectionProvider; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied {@link RedisClient}. * * @param redisClient must not be {@literal null}. */ public LettuceSentinelConnection(RedisClient redisClient) { Assert.notNull(redisClient, "Cannot create LettuceSentinelConnection using 'null' as client."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(redisClient.connectSentinel()); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied {@link RedisClient}. * * @param redisClient must not be {@literal null}. */ public LettuceSentinelConnection(RedisClient redisClient) { Assert.notNull(redisClient, "Cannot create LettuceSentinelConnection using 'null' as client."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(redisClient.connectSentinel()); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied redis connection. * * @param connection native Lettuce connection, must not be {@literal null} */ protected LettuceSentinelConnection(StatefulRedisSentinelConnection<String, String> connection) { Assert.notNull(connection, "Cannot create LettuceSentinelConnection using 'null' as connection."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(connection); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} using a supplied redis connection. * * @param connection native Lettuce connection, must not be {@literal null} */ protected LettuceSentinelConnection(StatefulRedisSentinelConnection<String, String> connection) { Assert.notNull(connection, "Cannot create LettuceSentinelConnection using 'null' as connection."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(connection); } }; init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port}. * * @param host must not be {@literal null}. * @param port sentinel port. */ public LettuceSentinelConnection(String host, int port) { Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port); init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port}. * * @param host must not be {@literal null}. * @param port sentinel port. */ public LettuceSentinelConnection(String host, int port) { Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port); init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port} and reuse * existing {@link ClientResources}. * * @param host must not be {@literal null}. * @param port sentinel port. * @param clientResources must not be {@literal null}. */ public LettuceSentinelConnection(String host, int port, ClientResources clientResources) { Assert.notNull(clientResources, "Cannot create LettuceSentinelConnection using 'null' as ClientResources."); Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port, clientResources); init(); }
/** * Creates a {@link LettuceSentinelConnection} with a client for the supplied {@code host} and {@code port} and reuse * existing {@link ClientResources}. * * @param host must not be {@literal null}. * @param port sentinel port. * @param clientResources must not be {@literal null}. */ public LettuceSentinelConnection(String host, int port, ClientResources clientResources) { Assert.notNull(clientResources, "Cannot create LettuceSentinelConnection using 'null' as ClientResources."); Assert.notNull(host, "Cannot create LettuceSentinelConnection using 'null' as host."); this.provider = new DedicatedClientConnectionProvider(host, port, clientResources); init(); }