本文整理汇总了Java中com.lambdaworks.redis.RedisURI.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java RedisURI.Builder方法的具体用法?Java RedisURI.Builder怎么用?Java RedisURI.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.RedisURI
的用法示例。
在下文中一共展示了RedisURI.Builder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
/**
* Connects to the Redis server.
* @param configuration The configuration object.
* @throws Exception If an error occurs.
*/
public void connect(Configuration configuration) throws Exception {
if(sync != null) {
return;
}
RedisURI.Builder uri = RedisURI.Builder.redis(configuration.getRedisHost(), configuration.getRedisPort())
.withDatabase(configuration.getRedisIndex());
if(!configuration.getRedisAuth().isEmpty()) {
uri.withPassword(configuration.getRedisAuth());
}
RedisClient client = RedisClient.create(uri.build());
StatefulRedisConnection<String, String> connection = client.connect();
sync = connection.sync();
for(Category category : Category.values()) {
logger.info("Registered the category {} with the type {}.", category, category.getEntry().getType());
category.getEntry().setCategory(category);
}
}
示例2: apply
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
@Override
public StatefulRedisConnection<K, V> apply(ConnectionKey key) {
RedisURI.Builder builder = RedisURI.Builder
.redis(key.host, key.port)
.withSsl(initialRedisUri.isSsl())
.withVerifyPeer(initialRedisUri.isVerifyPeer())
.withStartTls(initialRedisUri.isStartTls());
if (initialRedisUri.getPassword() != null && initialRedisUri.getPassword().length != 0) {
builder.withPassword(initialRedisUri.getPassword());
}
if (initialRedisUri.getClientName() != null) {
builder.withClientName(initialRedisUri.getClientName());
}
builder.withDatabase(initialRedisUri.getDatabase());
StatefulRedisConnection<K, V> connection = redisClient.connect(redisCodec, builder.build());
synchronized (stateLock) {
connection.setAutoFlushCommands(autoFlushCommands);
}
return connection;
}
示例3: RedisMasterSlaveNode
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
RedisMasterSlaveNode(String host, int port, RedisURI seed, Role role) {
RedisURI.Builder builder = RedisURI.Builder
.redis(host, port)
.withSsl(seed.isSsl())
.withVerifyPeer(seed.isVerifyPeer())
.withStartTls(seed.isStartTls());
if (seed.getPassword() != null && seed.getPassword().length != 0) {
builder.withPassword(new String(seed.getPassword()));
}
if (seed.getClientName() != null) {
builder.withClientName(seed.getClientName());
}
builder.withDatabase(seed.getDatabase());
this.redisURI = builder.build();
this.role = role;
}
示例4: configureRedisUri
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
private RedisURI configureRedisUri(Hosts.HostAndPort hostAndPort) {
RedisURI.Builder builder = redis( hostAndPort.getHost(), hostAndPort.getPort() );
builder.withSsl( config.isSsl() );
builder.withDatabase( config.getDatabaseNumber() );
if ( config.getPassword() != null ) {
builder.withPassword( config.getPassword() );
}
builder.withTimeout( config.getTimeout(), TimeUnit.MILLISECONDS );
return builder.build();
}