Skip to content

Commit

Permalink
Finish challenge redislabs-training#6
Browse files Browse the repository at this point in the history
  • Loading branch information
quyluongthanh committed Feb 7, 2023
1 parent f1f6292 commit f0187cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public FeedDaoRedisImpl(JedisPool jedisPool) {
public void insert(MeterReading meterReading) {
// START Challenge #6
// END Challenge #6

String globalFeedKey = RedisSchema.getGlobalFeedKey();
String feedKey = RedisSchema.getFeedKey(meterReading.getSiteId());

try (Jedis jedis = jedisPool.getResource()) {
Pipeline pipelined = jedis.pipelined();

pipelined.xadd(globalFeedKey, StreamEntryID.NEW_ENTRY, meterReading.toMap());
pipelined.xadd(feedKey, StreamEntryID.NEW_ENTRY, meterReading.toMap());

pipelined.sync();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void flush() {
}

// Challenge #6
@Ignore
// @Ignore
@Test
public void testBasicInsertReturnsRecent() {
FeedDao dao = new FeedDaoRedisImpl(jedisPool);
Expand Down

0 comments on commit f0187cf

Please sign in to comment.