Skip to content

Commit

Permalink
Bonus Challenge Week 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Govind Balaji S committed Oct 16, 2022
1 parent ae60212 commit 069f5a5
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ public Site findById(long id) {
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());
for (String key : keys) {
Map<String, String> site = jedis.hgetAll(key);
if (!site.isEmpty()) {
sites.add(new Site(site));
}
}
return sites;
Pipeline pipeline = jedis.pipelined();
Set<Response<Map<String, String>>> responses = keys.stream()
.map(pipeline::hgetAll).collect(Collectors.toSet());
pipeline.sync();
return responses.stream().map(Response::get)
.filter(map -> !map.isEmpty())
.map(Site::new).collect(Collectors.toSet());
}
}

Expand Down

0 comments on commit 069f5a5

Please sign in to comment.