Skip to content

Commit

Permalink
fix: cut MemoryCacheSpec by a tenth
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Pinson committed Jul 2, 2021
1 parent bc0c6f5 commit 211a94d
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofSingleImmutableMap should remove a value in mass delete") {
for {
cache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
_ <- cache.purgeExpired
value <- cache.lookupNoUpdate("Foo")
} yield {
Expand All @@ -41,9 +41,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofSingleImmutableMap should lookup after interval fails to get a value") {
for {
cache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookup("Foo")
} yield {
assertEquals(value, None)
Expand All @@ -53,10 +53,10 @@ class MemoryCacheSpec extends CatsEffectSuite {
test("MemoryCache.ofSingleImmutableMap should not Remove an item on lookup No Delete") {
for {
checkWasTouched <- Ref[IO].of(false)
iCache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
iCache <- MemoryCache.ofSingleImmutableMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
cache = iCache.setOnDelete(_ => checkWasTouched.set(true))
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookupNoUpdate("Foo")
wasTouched <- checkWasTouched.get
} yield {
Expand All @@ -67,7 +67,7 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofShardedImmutableMap should get a value in a quicker period than the timeout") {
for {
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(1.nano)
value <- cache.lookup("Foo")
Expand All @@ -78,7 +78,7 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofShardedImmutableMap should remove a value after delete") {
for {
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- cache.delete("Foo")
value <- cache.lookup("Foo")
Expand All @@ -89,9 +89,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofShardedImmutableMap should remove a value in mass delete") {
for {
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
_ <- cache.purgeExpired
value <- cache.lookupNoUpdate("Foo")
} yield {
Expand All @@ -101,9 +101,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofShardedImmutableMap should lookup after interval fails to get a value") {
for {
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookup("Foo")
} yield {
assertEquals(value, None)
Expand All @@ -113,10 +113,10 @@ class MemoryCacheSpec extends CatsEffectSuite {
test("MemoryCache.ofShardedImmutableMap should not Remove an item on lookup No Delete") {
for {
checkWasTouched <- Ref[IO].of(false)
iCache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
iCache <- MemoryCache.ofShardedImmutableMap[IO, String, Int](10, Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
cache = iCache.setOnDelete(_ => checkWasTouched.set(true))
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookupNoUpdate("Foo")
wasTouched <- checkWasTouched.get
} yield {
Expand All @@ -127,7 +127,7 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofConcurrentHashMap should get a value in a quicker period than the timeout") {
for {
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(1.nano)
value <- cache.lookup("Foo")
Expand All @@ -149,9 +149,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofConcurrentHashMap should Remove a value in mass delete") {
for {
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
_ <- cache.purgeExpired
value <- cache.lookupNoUpdate("Foo")
} yield {
Expand All @@ -161,9 +161,9 @@ class MemoryCacheSpec extends CatsEffectSuite {

test("MemoryCache.ofConcurrentHashMap should Lookup after interval fails to get a value") {
for {
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
cache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookup("Foo")
} yield {
assertEquals(value, None)
Expand All @@ -173,10 +173,10 @@ class MemoryCacheSpec extends CatsEffectSuite {
test("MemoryCache.ofConcurrentHashMap should Not Remove an item on lookup No Delete") {
for {
checkWasTouched <- Ref[IO].of(false)
iCache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)))(Async[IO])
iCache <- MemoryCache.ofConcurrentHashMap[IO, String, Int](Some(TimeSpec.unsafeFromDuration(100.millis)))(Async[IO])
cache = iCache.setOnDelete(_ => checkWasTouched.set(true))
_ <- cache.insert("Foo", 1)
_ <- IO.sleep(2.seconds)
_ <- IO.sleep(200.millis)
value <- cache.lookupNoUpdate("Foo")
wasTouched <- checkWasTouched.get
} yield {
Expand Down

0 comments on commit 211a94d

Please sign in to comment.