Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
victoriaum committed Feb 7, 2023
1 parent 6170608 commit 43ad40e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public FeedDaoRedisImpl(JedisPool jedisPool) {
@Override
public void insert(MeterReading meterReading) {
// START Challenge #6
try (Jedis jedis = jedisPool.getResource()) {
String globalFeedKey = RedisSchema.getGlobalFeedKey();
String siteFeedKey = RedisSchema.getFeedKey(meterReading.getSiteId());
Pipeline p = jedis.pipelined();
p.xadd(globalFeedKey, StreamEntryID.NEW_ENTRY, meterReading.toMap(),
globalMaxFeedLength, true);
p.xadd(siteFeedKey, StreamEntryID.NEW_ENTRY, meterReading.toMap(),
siteMaxFeedLength, true);
p.sync();
}
// END Challenge #6
}

Expand Down

0 comments on commit 43ad40e

Please sign in to comment.