Search in sources :

Example 76 with Pipeline

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"));
}
Also used : Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 77 with Pipeline

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);
    }
}
Also used : JedisConnectionException(redis.clients.jedis.exceptions.JedisConnectionException) Pipeline(redis.clients.jedis.Pipeline) Response(redis.clients.jedis.Response) Jedis(redis.clients.jedis.Jedis)

Aggregations

Pipeline (redis.clients.jedis.Pipeline)77 Test (org.junit.Test)72 Jedis (redis.clients.jedis.Jedis)12 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Map (java.util.Map)6 JedisDataException (redis.clients.jedis.exceptions.JedisDataException)6 HashMap (java.util.HashMap)5 Set (java.util.Set)3 Response (redis.clients.jedis.Response)3 LinkedHashMap (java.util.LinkedHashMap)2 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)1 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)1 RedisDataTypeDescription (org.apache.storm.redis.common.mapper.RedisDataTypeDescription)1 RedisClusterStateUpdater (org.apache.storm.redis.trident.state.RedisClusterStateUpdater)1 RedisState (org.apache.storm.redis.trident.state.RedisState)1 RedisStateUpdater (org.apache.storm.redis.trident.state.RedisStateUpdater)1 ISqlTridentDataSource (org.apache.storm.sql.runtime.ISqlTridentDataSource)1 StateUpdater (org.apache.storm.trident.state.StateUpdater)1 TridentTuple (org.apache.storm.trident.tuple.TridentTuple)1