use of redis.clients.jedis.Response in project cachecloud by sohutv.
the class TransactionCommandsTest method execGetResponse.
@Test
public void execGetResponse() {
Transaction t = jedis.multi();
t.set("foo", "bar");
t.smembers("foo");
t.get("foo");
List<Response<?>> lr = t.execGetResponse();
try {
lr.get(1).get();
fail("We expect exception here!");
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals("bar", lr.get(2).get());
}
use of redis.clients.jedis.Response in project cachecloud by sohutv.
the class PipeliningTest method multiWithMassiveRequests.
@Test
public void multiWithMassiveRequests() {
Pipeline p = jedis.pipelined();
p.multi();
List<Response<?>> responseList = new ArrayList<Response<?>>();
for (int i = 0; i < 100000; i++) {
// any operation should be ok, but shouldn't forget about timeout
responseList.add(p.setbit("test", 1, true));
}
Response<List<Object>> exec = p.exec();
p.sync();
// we don't need to check return value
// if below codes run without throwing Exception, we're ok
exec.get();
for (Response<?> resp : responseList) {
resp.get();
}
}
use of redis.clients.jedis.Response in project jedis by xetorthio.
the class PipeliningTest method multiWithMassiveRequests.
@Test
public void multiWithMassiveRequests() {
Pipeline p = jedis.pipelined();
p.multi();
List<Response<?>> responseList = new ArrayList<Response<?>>();
for (int i = 0; i < 100000; i++) {
// any operation should be ok, but shouldn't forget about timeout
responseList.add(p.setbit("test", 1, true));
}
Response<List<Object>> exec = p.exec();
p.sync();
// we don't need to check return value
// if below codes run without throwing Exception, we're ok
exec.get();
for (Response<?> resp : responseList) {
resp.get();
}
}
use of redis.clients.jedis.Response in project jedis by xetorthio.
the class TransactionCommandsTest method execGetResponse.
@Test
public void execGetResponse() {
Transaction t = jedis.multi();
t.set("foo", "bar");
t.smembers("foo");
t.get("foo");
List<Response<?>> lr = t.execGetResponse();
try {
lr.get(1).get();
fail("We expect exception here!");
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals("bar", lr.get(2).get());
}
use of redis.clients.jedis.Response 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