diff --git a/src/main/java/rx/Observable.java b/src/main/java/rx/Observable.java index cb701d936d..71c8635bb0 100644 --- a/src/main/java/rx/Observable.java +++ b/src/main/java/rx/Observable.java @@ -3664,6 +3664,15 @@ public final Observable cache() { return CachedObservable.from(this); } + /** + * @see #cacheWithInitialCapacity(int) + * @deprecated Use {@link #cacheWithInitialCapacity(int)} instead. + */ + @Deprecated + public final Observable cache(int initialCapacity) { + return cacheWithInitialCapacity(initialCapacity); + } + /** * Caches emissions from the source Observable and replays them in order to any subsequent Subscribers. * This method has similar behavior to {@link #replay} except that this auto-subscribes to the source @@ -3689,14 +3698,17 @@ public final Observable cache() { *
Scheduler:
*
{@code cache} does not operate by default on a particular {@link Scheduler}.
* + *

+ * Note: The capacity hint is not an upper bound on cache size. For that, consider + * {@link #replay(int)} in combination with {@link ConnectableObservable#autoConnect()} or similar. * - * @param capacityHint hint for number of items to cache (for optimizing underlying data structure) + * @param initialCapacity hint for number of items to cache (for optimizing underlying data structure) * @return an Observable that, when first subscribed to, caches all of its items and notifications for the * benefit of subsequent subscribers * @see ReactiveX operators documentation: Replay */ - public final Observable cache(int capacityHint) { - return CachedObservable.from(this, capacityHint); + public final Observable cacheWithInitialCapacity(int initialCapacity) { + return CachedObservable.from(this, initialCapacity); } /** diff --git a/src/test/java/rx/ObservableTests.java b/src/test/java/rx/ObservableTests.java index d59e8c41a9..2d6598132b 100644 --- a/src/test/java/rx/ObservableTests.java +++ b/src/test/java/rx/ObservableTests.java @@ -663,7 +663,7 @@ public void run() { } }).start(); } - }).cache(1); + }).cacheWithInitialCapacity(1); // we then expect the following 2 subscriptions to get that same value final CountDownLatch latch = new CountDownLatch(2);