redis.clients.jedis.Pipeline.hgetAll()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(445)

本文整理了Java中redis.clients.jedis.Pipeline.hgetAll()方法的一些代码示例,展示了Pipeline.hgetAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pipeline.hgetAll()方法的具体详情如下:
包路径:redis.clients.jedis.Pipeline
类名称:Pipeline
方法名:hgetAll

Pipeline.hgetAll介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
public void pipelineCommand(Pipeline pipeline, List<String> pipelineKeys) {
  for (String key : pipelineKeys) {
    pipeline.hgetAll(key);
  }
}

代码示例来源: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: spring-projects/spring-data-redis

@Override
public Map<byte[], byte[]> hGetAll(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().hgetAll(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hgetAll(key)));
      return null;
    }
    return connection.getJedis().hgetAll(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Response<Map<byte[], byte[]>> hgetAll(byte[] key) {
 String command = "hgetAll";
 return instrumented(command, () -> delegated.hgetAll(key));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Response<Map<String, String>> hgetAll(String key) {
 String command = "hgetAll";
 return instrumented(command, () -> delegated.hgetAll(key));
}

代码示例来源:origin: com.netflix.dyno/dyno-jedis

@Override
Response<Map<String, String>> execute(Pipeline jedisPipeline) throws DynoException {
  long startTime = System.nanoTime() / 1000;
  try {
    return jedisPipeline.hgetAll(key);
  } finally {
    long duration = System.nanoTime() / 1000 - startTime;
    opMonitor.recordSendLatency(OpName.HGETALL.name(), duration, TimeUnit.MICROSECONDS);
  }
}

代码示例来源:origin: com.netflix.dyno/dyno-jedis

@Override
  Response<Map<byte[], byte[]>> execute(Pipeline jedisPipeline) throws DynoException {
    long startTime = System.nanoTime() / 1000;
    try {
      return jedisPipeline.hgetAll(key);
    } finally {
      long duration = System.nanoTime() / 1000 - startTime;
      opMonitor.recordSendLatency(OpName.HGETALL.name(), duration, TimeUnit.MICROSECONDS);
    }
  }
}.execute(key, OpName.HGETALL);

代码示例来源:origin: hhfcyong/xxxx-dubbo

start = System.currentTimeMillis();
for (String key : keys) {
  responses.put(key, pipeline.hgetAll(key));

代码示例来源:origin: spinnaker/fiat

private Table<String, ResourceType, Response<Map<String, String>>> getAllFromRedis(Set<String> userIds) {
 if (userIds.size() == 0) {
  return HashBasedTable.create();
 }
 try {
  return redisClientDelegate.withMultiKeyPipeline(p -> {
   Table<String, ResourceType, Response<Map<String, String>>> responseTable =
     ArrayTable.create(userIds, new ArrayIterator<>(ResourceType.values()));
   for (String userId : userIds) {
    for (ResourceType r : ResourceType.values()) {
     responseTable.put(userId, r, p.hgetAll(userKey(userId, r)));
    }
   }
   p.sync();
   return responseTable;
  });
 } catch (Exception e) {
  log.error("Storage exception reading all entries.", e);
 }
 return null;
}

代码示例来源:origin: com.github.biezhi/unique-support-redis

@Override
  Map<String, String> execute() {
    Pipeline pipeline = jedis.getShard(key).pipelined();
    Response<Map<String, String>> result = pipeline.hgetAll(key);
    pipeline.expire(key, expire);
    pipeline.sync();
    return result.get();
  }
}.getResult();

代码示例来源:origin: com.netflix.spinnaker.fiat/fiat-roles

private Table<String, ResourceType, Response<Map<String, String>>> getAllFromRedis(Set<String> userIds) {
 if (userIds.size() == 0) {
  return HashBasedTable.create();
 }
 try {
  return redisClientDelegate.withMultiKeyPipeline(p -> {
   Table<String, ResourceType, Response<Map<String, String>>> responseTable =
     ArrayTable.create(userIds, new ArrayIterator<>(ResourceType.values()));
   for (String userId : userIds) {
    for (ResourceType r : ResourceType.values()) {
     responseTable.put(userId, r, p.hgetAll(userKey(userId, r)));
    }
   }
   p.sync();
   return responseTable;
  });
 } catch (Exception e) {
  log.error("Storage exception reading all entries.", e);
 }
 return null;
}

代码示例来源:origin: spinnaker/fiat

@Override
public Optional<UserPermission> get(@NonNull String id) {
 try {
  return redisClientDelegate.withMultiKeyPipeline(p -> {
   RawUserPermission userResponseMap = new RawUserPermission();
   RawUserPermission unrestrictedResponseMap = new RawUserPermission();
   Response<Boolean> isUserInRepo = p.sismember(allUsersKey(), id);
   for (ResourceType r : ResourceType.values()) {
    Response<Map<String, String>> resourceMap = p.hgetAll(userKey(id, r));
    userResponseMap.put(r, resourceMap);
    Response<Map<String, String>> unrestrictedMap = p.hgetAll(unrestrictedUserKey(r));
    unrestrictedResponseMap.put(r, unrestrictedMap);
   }
   Response<Boolean> admin = p.sismember(adminKey(), id);
   p.sync();
   if (!isUserInRepo.get()) {
    return Optional.empty();
   }
   userResponseMap.isAdmin = admin.get();
   UserPermission unrestrictedUser = getUserPermission(UNRESTRICTED, unrestrictedResponseMap);
   return Optional.of(getUserPermission(id, userResponseMap).merge(unrestrictedUser));
  });
 } catch (Exception e) {
  log.error("Storage exception reading " + id + " entry.", e);
 }
 return Optional.empty();
}

代码示例来源:origin: com.netflix.spinnaker.fiat/fiat-roles

@Override
public Optional<UserPermission> get(@NonNull String id) {
 try {
  return redisClientDelegate.withMultiKeyPipeline(p -> {
   RawUserPermission userResponseMap = new RawUserPermission();
   RawUserPermission unrestrictedResponseMap = new RawUserPermission();
   Response<Boolean> isUserInRepo = p.sismember(allUsersKey(), id);
   for (ResourceType r : ResourceType.values()) {
    Response<Map<String, String>> resourceMap = p.hgetAll(userKey(id, r));
    userResponseMap.put(r, resourceMap);
    Response<Map<String, String>> unrestrictedMap = p.hgetAll(unrestrictedUserKey(r));
    unrestrictedResponseMap.put(r, unrestrictedMap);
   }
   Response<Boolean> admin = p.sismember(adminKey(), id);
   p.sync();
   if (!isUserInRepo.get()) {
    return Optional.empty();
   }
   userResponseMap.isAdmin = admin.get();
   UserPermission unrestrictedUser = getUserPermission(UNRESTRICTED, unrestrictedResponseMap);
   return Optional.of(getUserPermission(id, userResponseMap).merge(unrestrictedUser));
  });
 } catch (Exception e) {
  log.error("Storage exception reading " + id + " entry.", e);
 }
 return Optional.empty();
}

代码示例来源:origin: pinterest/pinlater

for (Tuple tuple : jobIdScoreTuples) {
 String jobIdStr = tuple.getElement();
 jobIdToDetails.put(jobIdStr, pipeline.hgetAll(String.format(
   "%s%s",
   RedisBackendUtils.constructHashRedisKeyPrefix(queueName, shardName),

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public Map<byte[], byte[]> hGetAll(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().hgetAll(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hgetAll(key)));
      return null;
    }
    return connection.getJedis().hgetAll(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Map<byte[], byte[]> hGetAll(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().hgetAll(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hgetAll(key)));
      return null;
    }
    return connection.getJedis().hgetAll(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: pyloque/captain

public ServiceSet serviceSet(String name) {
  Holder<Response<Long>> version = new Holder<Response<Long>>();
  Holder<Response<Set<Tuple>>> services = new Holder<Response<Set<Tuple>>>();
  Holder<Response<Map<String, String>>> payloadsHolder = new Holder<Response<Map<String, String>>>();
  this.redis.pipeline(pipe -> {
    version.set(pipe.incrBy(keyForVersion(name), 0));
    services.set(pipe.zrangeWithScores(keyForSet(name), 0, -1));
    payloadsHolder.set(pipe.hgetAll(keyForPayload(name)));
  });
  Set<ServiceItem> items = new HashSet<ServiceItem>();
  long now = System.currentTimeMillis() / 1000;
  Map<String, String> payloads = payloadsHolder.value().get();
  for (Tuple tuple : services.value().get()) {
    String[] pair = tuple.getElement().split(":");
    String host = pair[0];
    int port = Integer.parseInt(pair[1]);
    int ttl = (int) (tuple.getScore() - now);
    String payload = payloads.get(tuple.getElement());
    items.add(new ServiceItem(name, host, port, ttl, payload));
  }
  ServiceSet set = new ServiceSet(name, items, version.value().get());
  if (set.isEmpty()) {
    this.redis.execute(jedis -> {
      jedis.srem(nameKeys, name);
    });
  }
  return set;
}

相关文章

Pipeline类方法