本文整理汇总了Java中com.lambdaworks.redis.api.StatefulRedisConnection.setAutoFlushCommands方法的典型用法代码示例。如果您正苦于以下问题:Java StatefulRedisConnection.setAutoFlushCommands方法的具体用法?Java StatefulRedisConnection.setAutoFlushCommands怎么用?Java StatefulRedisConnection.setAutoFlushCommands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.api.StatefulRedisConnection
的用法示例。
在下文中一共展示了StatefulRedisConnection.setAutoFlushCommands方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的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;
}
示例2: basic
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void basic() throws Exception {
StatefulRedisConnection<String, String> connection = client.connect();
connection.setAutoFlushCommands(false);
int iterations = 100;
List<RedisFuture<?>> futures = triggerSet(connection.async(), iterations);
verifyNotExecuted(iterations);
connection.flushCommands();
LettuceFutures.awaitAll(5, TimeUnit.SECONDS, futures.toArray(new RedisFuture[futures.size()]));
verifyExecuted(iterations);
connection.close();
}
示例3: setAutoFlushTrueDoesNotFlush
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void setAutoFlushTrueDoesNotFlush() throws Exception {
StatefulRedisConnection<String, String> connection = client.connect();
connection.setAutoFlushCommands(false);
int iterations = 100;
List<RedisFuture<?>> futures = triggerSet(connection.async(), iterations);
verifyNotExecuted(iterations);
connection.setAutoFlushCommands(true);
verifyNotExecuted(iterations);
connection.flushCommands();
boolean result = LettuceFutures.awaitAll(5, TimeUnit.SECONDS, futures.toArray(new RedisFuture[futures.size()]));
assertThat(result).isTrue();
connection.close();
}