本文整理了Java中com.lambdaworks.redis.RedisClient.create
方法的一些代码示例,展示了RedisClient.create
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisClient.create
方法的具体详情如下:
包路径:com.lambdaworks.redis.RedisClient
类名称:RedisClient
方法名:create
暂无
代码示例来源: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());
代码示例来源:origin: danhyun/modern-java-web
@Provides
@Singleton
public RedisClient redisClient(RedisConfig config) {
return RedisClient.create(config.getUrl());
}
代码示例来源: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: 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: 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: 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: 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;
}
代码示例来源:origin: longkerdandy/mithqtt
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("single")) {
throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
// lettuce
RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
this.lettuce = RedisClient.create(lettuceURI);
this.lettuceConn = this.lettuce.connect();
// params
initParams(config);
}
代码示例来源:origin: longkerdandy/mithqtt
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("master_slave")) {
throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
// lettuce
RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
this.lettuceMasterSlave = RedisClient.create(lettuceURI);
this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// params
initParams(config);
}
代码示例来源:origin: longkerdandy/mithqtt
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("sentinel")) {
throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
String masterId = config.getString("redis.master");
// lettuce
RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
this.lettuceSentinel = RedisClient.create(lettuceURI);
this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// params
initParams(config);
}
代码示例来源: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: 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();
}
内容来源于网络,如有侵权,请联系作者删除!