Skip to content

Commit

Permalink
Optional challenge geo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mate0021 committed Mar 17, 2022
1 parent 73f3142 commit 9e9b61b
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@ public Set<Site> findAll() {
try (Jedis jedis = jedisPool.getResource()) {
Set<String> keys = jedis.zrange(RedisSchema.getSiteGeoKey(), 0, -1);
Set<Site> sites = new HashSet<>(keys.size());

Pipeline p = jedis.pipelined();

List<Response<Map<String, String>>> allResponses = new ArrayList<>();
for (String key : keys) {
Map<String, String> site = jedis.hgetAll(key);
if (!site.isEmpty()) {
sites.add(new Site(site));
allResponses.add(p.hgetAll(key));
}
p.sync();

for (Response<Map<String, String>> response : allResponses) {
if (!response.get().isEmpty()) {
sites.add(new Site(response.get()));
}
}

return sites;
}
}
Expand Down

0 comments on commit 9e9b61b

Please sign in to comment.