This repository was archived by the owner on Mar 2, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
main/scala/reactor/core/scala/publisher
test/scala/reactor/core/scala/publisher Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -165,9 +165,9 @@ class Mono[T] private(private val jMono: JMono[T]) extends Publisher[T] with Map
165165 *
166166 * @return a replaying [[Mono ]]
167167 */
168- final def cache (): Mono [T ] = Mono [T ](
169- jMono.cache()
170- )
168+ final def cache (): Mono [T ] = Mono [T ](jMono.cache())
169+
170+ final def cache ( ttl : Duration ) = Mono (jMono.cache(ttl) )
171171
172172 /**
173173 * Prepare this [[Mono ]] so that subscribers will cancel from it on a
Original file line number Diff line number Diff line change @@ -412,10 +412,17 @@ class MonoTest extends FreeSpec with Matchers with TableDrivenPropertyChecks wit
412412 number shouldBe a[ScalaNumber ]
413413 }
414414
415- " .cache should call the underlying cache method" in {
416- val jMono = spy(JMono .just(1 ))
417- Mono (jMono).cache()
418- Mockito .verify(jMono).cache()
415+ " .cache" - {
416+ " should call the underlying cache method" in {
417+ val jMono = spy(JMono .just(1 ))
418+ Mono (jMono).cache()
419+ Mockito .verify(jMono).cache()
420+ }
421+ " with ttl should call the underlying cache method" in {
422+ val jMono = spy(JMono .just(1 ))
423+ Mono (jMono).cache(10 seconds)
424+ Mockito .verify(jMono).cache(10 seconds)
425+ }
419426 }
420427
421428 " .cancelOn should cancel the subscriber on a particular scheduler" in {
You can’t perform that action at this time.
0 commit comments