Permalink
Browse files

Get range should also get the whole timeline

  • Loading branch information...
1 parent 26ca115 commit 5f52727bc75e81b45fc42daf8359a4d22d33ee4b Gary Tsang committed Nov 8, 2011
@@ -190,13 +190,13 @@ class RedisShard(val shardInfo: ShardInfo, val weight: Int, val children: Seq[Ha
Stats.timeMicros("redisshard-get-usec") {
readPool.withClient(shardInfo) { client =>
// we've changed the size semantics to always return the size of theresult set.
- val entries = client.get(timeline, 0, -1)
+ val results = client.get(timeline, 0, -1)
- if (entries.isEmpty) {
+ if (results.isEmpty) {
None
} else {
- val filtered = entries filter isSentinel
- val filteredEntries = dedupe(filtered, dedupeSecondary).slice(offset, length)
+ val entries = results filter isSentinel
+ val filteredEntries = dedupe(entries, dedupeSecondary).slice(offset, length)
Some(TimelineSegment(filteredEntries, filteredEntries.size))
}
}
@@ -211,7 +211,7 @@ class RedisShard(val shardInfo: ShardInfo, val weight: Int, val children: Seq[Ha
def getRange(timeline: String, fromId: Long, toId: Long, dedupeSecondary: Boolean): Option[TimelineSegment] = {
readPool.withClient(shardInfo) { client =>
- val results = client.get(timeline, 0, 600)
+ val results = client.get(timeline, 0, -1)
if (results.size > 0) {
val entries = dedupe(results, dedupeSecondary)
@@ -301,7 +301,7 @@ object RedisShardSpec extends ConfiguredSpecification with JMocker with ClassMoc
"with missing fromId" in {
expect {
one(shardInfo).hostname willReturn "host1"
- lrange(timeline, -600, -1, List(entry23, entry20, entry19, entry10).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry19, entry10).reverse)
one(jredis).expire(timeline, 1)
}
@@ -312,7 +312,7 @@ object RedisShardSpec extends ConfiguredSpecification with JMocker with ClassMoc
"with fromId" in {
expect {
one(shardInfo).hostname willReturn "host1"
- lrange(timeline, -600, -1, List(entry23, entry20, entry19, entry10).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry19, entry10).reverse)
one(jredis).expire(timeline, 1)
}
@@ -323,11 +323,11 @@ object RedisShardSpec extends ConfiguredSpecification with JMocker with ClassMoc
"with toId" in {
expect {
allowing(shardInfo).hostname willReturn "host1"
- lrange(timeline, -600, -1, List(entry23, entry20, entry19).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry19).reverse)
one(jredis).expire(timeline, 1)
- lrange(timeline, -600, -1, List(entry23, entry20, entry19).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry19).reverse)
one(jredis).expire(timeline, 1)
- lrange(timeline, -600, -1, List(entry23, entry20, entry19).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry19).reverse)
one(jredis).expire(timeline, 1)
allowing(jredis).expire(timeline, 1)
}
@@ -341,7 +341,7 @@ object RedisShardSpec extends ConfiguredSpecification with JMocker with ClassMoc
"with dupes" in {
expect {
one(shardInfo).hostname willReturn "host1"
- lrange(timeline, -600, -1, List(entry23, entry20, entry20,entry20, entry17, entry13).reverse)
+ lrange(timeline, 0, -1, List(entry23, entry20, entry20,entry20, entry17, entry13).reverse)
one(jredis).expire(timeline, 1)
}
@@ -352,7 +352,7 @@ object RedisShardSpec extends ConfiguredSpecification with JMocker with ClassMoc
"miss" in {
expect {
one(shardInfo).hostname willReturn "host1"
- one(jredis).lrange(timeline, -600, -1) willReturn future
+ one(jredis).lrange(timeline, 0, -1) willReturn future
one(future).get(1000, TimeUnit.MILLISECONDS) willReturn (Seq[TimelineEntry]()).toJavaList
}

0 comments on commit 5f52727

Please sign in to comment.