use of redis.clients.jedis.Pipeline in project jedis by xetorthio.
the class TransactionCommandsTest method testResetStateWhenInMultiWithinPipeline.
@Test
public void testResetStateWhenInMultiWithinPipeline() {
jedis.auth("foobared");
Pipeline p = jedis.pipelined();
p.multi();
p.set("foooo", "barrr");
jedis.resetState();
assertEquals(null, jedis.get("foooo"));
}
use of redis.clients.jedis.Pipeline in project jetcache by alibaba.
the class RedisCache method do_PUT_ALL.
@Override
protected CacheResult do_PUT_ALL(Map<? extends K, ? extends V> map, long expireAfterWrite, TimeUnit timeUnit) {
if (map == null) {
return CacheResult.FAIL_ILLEGAL_ARGUMENT;
}
try (Jedis jedis = pool.getResource()) {
int failCount = 0;
List<Response<String>> responses = new ArrayList<>();
Pipeline p = jedis.pipelined();
for (Map.Entry<? extends K, ? extends V> en : map.entrySet()) {
CacheValueHolder<V> holder = new CacheValueHolder(en.getValue(), timeUnit.toMillis(expireAfterWrite));
Response<String> resp = p.psetex(buildKey(en.getKey()), timeUnit.toMillis(expireAfterWrite), valueEncoder.apply(holder));
responses.add(resp);
}
p.sync();
for (Response<String> resp : responses) {
if (!"OK".equals(resp.get())) {
failCount++;
}
}
return failCount == 0 ? CacheResult.SUCCESS_WITHOUT_MSG : failCount == map.size() ? CacheResult.FAIL_WITHOUT_MSG : CacheResult.PART_SUCCESS_WITHOUT_MSG;
} catch (Exception ex) {
logError("PUT_ALL", "map(" + map.size() + ")", ex);
return new CacheResult(ex);
}
}
Aggregations