@Override public void pipelineCommand(Pipeline pipeline, List<String> pipelineKeys) { for (String key : pipelineKeys) { pipeline.hgetAll(key); } }
@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; } });
@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); } }
@Override public Response<Map<byte[], byte[]>> hgetAll(byte[] key) { String command = "hgetAll"; return instrumented(command, () -> delegated.hgetAll(key)); }
@Override public Response<Map<String, String>> hgetAll(String key) { String command = "hgetAll"; return instrumented(command, () -> delegated.hgetAll(key)); }
@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); } }
@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);
start = System.currentTimeMillis(); for (String key : keys) { responses.put(key, pipeline.hgetAll(key));
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; }
@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();
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; }
@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(); }
@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(); }
for (Tuple tuple : jobIdScoreTuples) { String jobIdStr = tuple.getElement(); jobIdToDetails.put(jobIdStr, pipeline.hgetAll(String.format( "%s%s", RedisBackendUtils.constructHashRedisKeyPrefix(queueName, shardName),
@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); } }
@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); } }
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; }