Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ndy2 committed May 26, 2023
1 parent 182bdbc commit 04f5ef4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Tuple;

/**
Expand Down Expand Up @@ -53,6 +54,12 @@ private void insertMetric(Jedis jedis, long siteId, double value, MetricUnit uni
// START Challenge #2
String metricKey = RedisSchema.getDayMetricKey(siteId, unit, dateTime);
Integer minuteOfDay = getMinuteOfDay(dateTime);

Pipeline pipeline = jedis.pipelined();
pipeline.zadd(metricKey, minuteOfDay, new MeasurementMinute(value,
minuteOfDay).toString());
pipeline.expire(metricKey, METRIC_EXPIRATION_SECONDS);
pipeline.sync();
// END Challenge #2
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ public void generateData() {
}

// Challenge #2
@Ignore
@Test
public void testSmall() {
testInsertAndRetrieve(1);
}

// Challenge #2
@Ignore
@Test
public void testOneDay() {
testInsertAndRetrieve(60 * 24);
}

// Challenge #2
@Ignore
@Test
public void testMultipleDays() {
testInsertAndRetrieve(60 * 70);
Expand Down

0 comments on commit 04f5ef4

Please sign in to comment.