@Override public void openPipeline() { if (pipeline == null) { pipeline = jedis.pipelined(); } }
@Override public List<Transaction> doInJedis(Jedis jedis) { Pipeline pipeline = jedis.pipelined(); for (final byte[] key : keys) { pipeline.hgetAll(key); } List<Object> result = pipeline.syncAndReturnAll(); List<Transaction> list = new ArrayList<Transaction>(); for (Object data : result) { if (data != null && ((Map<byte[], byte[]>) data).size() > 0) { list.add(ExpandTransactionSerializer.deserialize(serializer, (Map<byte[], byte[]>) data)); } } return list; } });
public BatchOperationHandle startBatchOperation() { Jedis jedis = redisPool.getWriteResource(); return new BatchOperationHandle(jedis, jedis.pipelined()); }
try { jedis = jedisPool.getResource(); pipeline = jedis.pipelined(); pipelineCommand(pipeline, subkeys); subResultList = pipeline.syncAndReturnAll();
@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); } }
@Override public void hset(byte[] key, byte[] field, byte[] value, int seconds) { Jedis jedis = shardedJedis.getShard(key); Pipeline pipeline = jedis.pipelined(); pipeline.hset(key, field, value); pipeline.expire(key, seconds); pipeline.sync(); }
try { jedis = redisState.getJedis(); Pipeline pipeline = jedis.pipelined();
public List<ClientContact> get(List<byte[]> tokens) { try (Jedis jedis = redisPool.getWriteResource()) { Pipeline pipeline = jedis.pipelined(); List<Response<byte[]>> futures = new LinkedList<>(); List<ClientContact> results = new LinkedList<>(); try { for (byte[] token : tokens) { futures.add(pipeline.hget(DIRECTORY_KEY, token)); } } finally { pipeline.sync(); } IterablePair<byte[], Response<byte[]>> lists = new IterablePair<>(tokens, futures); for (Pair<byte[], Response<byte[]>> pair : lists) { try { if (pair.second().get() != null) { TokenValue tokenValue = objectMapper.readValue(pair.second().get(), TokenValue.class); ClientContact clientContact = new ClientContact(pair.first(), tokenValue.relay, tokenValue.voice, tokenValue.video); results.add(clientContact); } } catch (IOException e) { logger.warn("Deserialization Problem: ", e); } } return results; } }
jedis.mset(keyValue); if (this.options.expireIntervalSec > 0) { Pipeline pipe = jedis.pipelined(); for (int i = 0; i < keyValue.length; i += 2) { pipe.expire(keyValue[i], this.options.expireIntervalSec);
pipeLine = ((Jedis) this.pipeLineOrConnection).pipelined(); pipeLine.zadd(idx_Name, value, parentId.toString());
@Override protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders) { Object connection = getConnection(); // Create a hashset and populate data into it // Pipeline pipeLine = null; try { if (isBoundTransaction()) { pipeLine = ((Jedis) connection).pipelined(); onPersist(entityMetadata, entity, id, rlHolders, pipeLine); } else { onPersist(entityMetadata, entity, id, rlHolders, connection); } } finally { // if (pipeLine != null) { pipeLine.sync(); // send I/O.. as persist call. so no need to // read } // response? onCleanup(connection); } }
@Override public void delete(Object entity, Object pKey) { EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass()); Object connection = getConnection(); Pipeline pipeLine = null; try { if (isBoundTransaction()) { pipeLine = ((Jedis) connection).pipelined(); onDelete(entity, pKey, pipeLine); } else { onDelete(entity, pKey, connection); } getIndexManager().remove(metadata, entity, pKey); } finally { if (pipeLine != null) { pipeLine.sync(); } onCleanup(connection); } }
@Override public void openPipeline() { if (pipeline == null) { pipeline = jedis.pipelined(); } }
if (isBoundTransaction()) pipeline = ((Jedis) connection).pipelined();
if (isBoundTransaction()) pipeLine = ((Jedis) connection).pipelined();
@Override @Deprecated public List<Object> pipelined(PipelineBlock jedisPipeline) { String command = "pipelined"; return instrumented(command, () -> delegated.pipelined(jedisPipeline)); }
pipeLine = ((Jedis) connection).pipelined();
public <T> void safeForEach(Collection<T> collection, BiConsumer<Pipeline, T> f) { safelyReturn(jedis -> { Pipeline p = jedis.pipelined(); collection.stream().forEach(e -> f.accept(p, e)); p.sync(); return null; }); }
public Long execute(final Jedis conn) throws Exception { Pipeline pipe = conn.pipelined(); byte[] bk = SafeEncoder.encode(key); for(String field : nums.keySet()){ pipe.hincrBy(bk, SafeEncoder.encode(field), nums.get(field)); } pipe.exec(); return 1L; } });
@Override String execute() { Pipeline pipeline = jedis.getShard(key).pipelined(); Response<String> result = pipeline.hget(key, field); pipeline.expire(key, expire); pipeline.sync(); return result.get(); } }.getResult();