本文整理了Java中redis.clients.jedis.Jedis.pipelined()
方法的一些代码示例,展示了Jedis.pipelined()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.pipelined()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:pipelined
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public void openPipeline() {
if (pipeline == null) {
pipeline = jedis.pipelined();
}
}
代码示例来源:origin: changmingxie/tcc-transaction
@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;
}
});
代码示例来源:origin: signalapp/Signal-Server
public BatchOperationHandle startBatchOperation() {
Jedis jedis = redisPool.getWriteResource();
return new BatchOperationHandle(jedis, jedis.pipelined());
}
代码示例来源:origin: sohutv/cachecloud
try {
jedis = jedisPool.getResource();
pipeline = jedis.pipelined();
pipelineCommand(pipeline, subkeys);
subResultList = pipeline.syncAndReturnAll();
代码示例来源:origin: alibaba/jetcache
@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);
}
}
代码示例来源:origin: qiujiayu/AutoLoadCache
@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();
}
代码示例来源:origin: apache/storm
try {
jedis = redisState.getJedis();
Pipeline pipeline = jedis.pipelined();
代码示例来源:origin: signalapp/Signal-Server
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;
}
}
代码示例来源:origin: apache/storm
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);
代码示例来源:origin: Impetus/Kundera
pipeLine = ((Jedis) this.pipeLineOrConnection).pipelined();
pipeLine.zadd(idx_Name, value, parentId.toString());
代码示例来源:origin: Impetus/Kundera
@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);
}
}
代码示例来源:origin: Impetus/Kundera
@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);
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public void openPipeline() {
if (pipeline == null) {
pipeline = jedis.pipelined();
}
}
代码示例来源:origin: Impetus/Kundera
if (isBoundTransaction())
pipeline = ((Jedis) connection).pipelined();
代码示例来源:origin: Impetus/Kundera
if (isBoundTransaction())
pipeLine = ((Jedis) connection).pipelined();
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
@Deprecated
public List<Object> pipelined(PipelineBlock jedisPipeline) {
String command = "pipelined";
return instrumented(command, () -> delegated.pipelined(jedisPipeline));
}
代码示例来源:origin: Impetus/Kundera
pipeLine = ((Jedis) connection).pipelined();
代码示例来源:origin: Baqend/Orestes-Bloomfilter
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;
});
}
代码示例来源:origin: com.github.yamingd.argo/argo-redis
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;
}
});
代码示例来源:origin: com.github.biezhi/unique-support-redis
@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();
内容来源于网络,如有侵权,请联系作者删除!