本文整理了Java中com.lambdaworks.redis.RedisClient
类的一些代码示例,展示了RedisClient
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisClient
类的具体详情如下:
包路径:com.lambdaworks.redis.RedisClient
类名称:RedisClient
[英]A scalable thread-safe Redis client. Multiple threads may share one connection provided they avoid blocking and transactional operations such as BLPOP and MULTI/EXEC.
[中]一个可伸缩的线程安全{0$}客户端。多个线程可以共享一个连接,前提是它们避免阻塞和事务性操作,如BLPOP和MULTI/EXEC。
代码示例来源:origin: alibaba/jetcache
public StatefulConnection connection(AbstractRedisClient redisClient) {
LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
if (lo.connection == null) {
if (redisClient instanceof RedisClient) {
lo.connection = ((RedisClient) redisClient).connect(new JetCacheCodec());
} else if (redisClient instanceof RedisClusterClient) {
lo.connection = ((RedisClusterClient) redisClient).connect(new JetCacheCodec());
} else {
throw new CacheConfigException("type " + redisClient.getClass() + " is not supported");
}
}
return lo.connection;
}
代码示例来源:origin: QNJR-GROUP/EasyTransaction
public RedisAsyncCommanderProvider(String uri){
RedisClient client = RedisClient.create(uri);
StatefulRedisConnection<String, byte[]> connect = client.connect(getCodec());
cmd = connect.async();
}
代码示例来源:origin: alibaba/jetcache
} else if (map.size() == 1) {
String uri = (String) map.values().iterator().next();
client = RedisClient.create(uri);
((RedisClient)client).setOptions(ClientOptions.builder().
disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build());
} else {
代码示例来源:origin: udacity/ud381
@Override
public void prepare(
Map map,
TopologyContext topologyContext,
OutputCollector outputCollector)
{
// instantiate a redis connection
RedisClient client = new RedisClient("localhost",6379);
// initiate the actual connection
redis = client.connect();
}
代码示例来源:origin: geek-xuzi/lettuce-redis
public RedisAsyncCommands<String, String> buildAsync() {
RedisURI redisURI = redisURIBuilder()
.withTimeout(timeout, timeoutUnit)
.withPassword(password)
.build();
RedisClient redisClient = RedisClient.create(redisURI);
redisClient.setOptions(buildClientOptions());
return redisClient.connect().async();
}
代码示例来源:origin: danhyun/modern-java-web
@Provides
@Singleton
public RedisClient redisClient(RedisConfig config) {
return RedisClient.create(config.getUrl());
}
代码示例来源:origin: org.apache.apex/malhar-contrib
@Override
public void disconnect() throws IOException
{
client.shutdown();
connection = null;
}
代码示例来源:origin: udacity/ud381
@Override
public void prepare(
Map map,
TopologyContext topologyContext,
OutputCollector outputCollector)
{
// instantiate a redis connection
RedisClient client = new RedisClient("localhost",6379);
// initiate the actual connection
redis = client.connect();
}
代码示例来源:origin: geek-xuzi/lettuce-redis
public RedisCommands<String, String> buildSync() {
RedisURI redisURI = redisURIBuilder()
.withTimeout(timeout, timeoutUnit)
.withPassword(password)
.build();
RedisClient redisClient = RedisClient.create(redisURI);
redisClient.setOptions(buildClientOptions());
return redisClient.connect().sync();
}
代码示例来源:origin: yahoo/sherlock
/**
* Initialize the {@code RedisClient} if it has not already been.
*
* @param params Store params used to create a Redis URI
*/
public void initializeRedisClient(StoreParams params) {
if (redisClient != null) {
return;
}
redisClient = RedisClient.create(produceURI(params));
}
代码示例来源:origin: apache/apex-malhar
@Override
public void disconnect() throws IOException
{
client.shutdown();
connection = null;
}
代码示例来源:origin: udacity/ud381
@Override
public void prepare(
Map map,
TopologyContext topologyContext,
OutputCollector outputCollector)
{
// instantiate a redis connection
RedisClient client = new RedisClient("localhost",6379);
// initiate the actual connection
redis = client.connect();
}
代码示例来源:origin: com.hortonworks.registries/cache
@Override
public RedisConnection<K, V> create() {
return redisClient.connect(codec);
}
}
代码示例来源:origin: com.hortonworks.registries/cache
private static void setConnection() {
// RedisClient redisClient = RedisClient.create(new RedisURI("127.0.0.1", 6379, 10L, TimeUnit.SECONDS));
RedisClient redisClient = RedisClient.create("redis://127.0.0.1:6379");
// RedisClient redisClient = RedisClient.create(new RedisURI.Builder.redis("127.0.0.1", 6379).build());
connection = redisClient.connect();
connection1 = redisClient.connect();
}
代码示例来源:origin: com.hortonworks.registries/cache
private Factory<RedisConnection> getRedisConnectionFactory() {
final ConnectionConfig.RedisConnectionConfig connectionConfig = (ConnectionConfig.RedisConnectionConfig) cacheConfig.getConnectionConfig();
if (connectionConfig != null) {
if (connectionConfig.getPool() != null) {
return new RedisConnectionPoolFactory(RedisClient.create(getRedisUri()), getRedisCodec());
} else {
return new RedisConnectionFactory(RedisClient.create(getRedisUri()), getRedisCodec());
}
}
return null;
}
代码示例来源:origin: longkerdandy/mithqtt
@Override
public void destroy() {
// shutdown this client and close all open connections
if (this.lettuceSentinelConn != null) this.lettuceSentinelConn.close();
if (this.lettuceSentinel != null) this.lettuceSentinel.shutdown();
}
}
代码示例来源:origin: udacity/ud381
@Override
public void prepare(
Map map,
TopologyContext topologyContext,
OutputCollector outputCollector)
{
// instantiate a redis connection
RedisClient client = new RedisClient("localhost",6379);
// initiate the actual connection
redis = client.connect();
}
代码示例来源:origin: hortonworks/registry
@Override
public RedisConnection<K, V> create() {
return redisClient.connect(codec);
}
}
代码示例来源:origin: hortonworks/registry
private static void setConnection() {
// RedisClient redisClient = RedisClient.create(new RedisURI("127.0.0.1", 6379, 10L, TimeUnit.SECONDS));
RedisClient redisClient = RedisClient.create("redis://127.0.0.1:6379");
// RedisClient redisClient = RedisClient.create(new RedisURI.Builder.redis("127.0.0.1", 6379).build());
connection = redisClient.connect();
connection1 = redisClient.connect();
}
代码示例来源:origin: hortonworks/registry
private Factory<RedisConnection> getRedisConnectionFactory() {
final ConnectionConfig.RedisConnectionConfig connectionConfig = (ConnectionConfig.RedisConnectionConfig) cacheConfig.getConnectionConfig();
if (connectionConfig != null) {
if (connectionConfig.getPool() != null) {
return new RedisConnectionPoolFactory(RedisClient.create(getRedisUri()), getRedisCodec());
} else {
return new RedisConnectionFactory(RedisClient.create(getRedisUri()), getRedisCodec());
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!