diff --git a/modules/core/src/test/scala/io/chrisdavenport/mules/MemoryCacheSpec.scala b/modules/core/src/test/scala/io/chrisdavenport/mules/MemoryCacheSpec.scala index 9bb32f4..e277782 100644 --- a/modules/core/src/test/scala/io/chrisdavenport/mules/MemoryCacheSpec.scala +++ b/modules/core/src/test/scala/io/chrisdavenport/mules/MemoryCacheSpec.scala @@ -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 { @@ -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) @@ -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 { @@ -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") @@ -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") @@ -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 { @@ -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) @@ -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 { @@ -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") @@ -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 { @@ -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) @@ -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 {