@@ -3361,8 +3361,6 @@ public final <B> Observable<List<T>> buffer(Observable<B> boundary, int initialC
3361
3361
* {@code subscribe} method.
3362
3362
* <p>
3363
3363
*
3364
- * <!-- IS THE FOLLOWING NOTE STILL VALID??? -->
3365
- *
3366
3364
* <em>Note:</em> You sacrifice the ability to unsubscribe from the origin when you use the {@code cache}
3367
3365
* Observer so be careful not to use this Observer on Observables that emit an infinite or very large number
3368
3366
* of items that will use up memory.
@@ -3379,10 +3377,29 @@ public final Observable<T> cache() {
3379
3377
}
3380
3378
3381
3379
/**
3382
- * {@code cache} with initial capacity.
3380
+ * Caches emissions from the source Observable and replays them in order to any subsequent Subscribers.
3381
+ * This method has similar behavior to {@link #replay} except that this auto-subscribes to the source
3382
+ * Observable rather than returning a {@link ConnectableObservable} for which you must call
3383
+ * {@code connect} to activate the subscription.
3384
+ * <p>
3385
+ * <img width="640" height="410" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/cache.png" alt="">
3386
+ * <p>
3387
+ * This is useful when you want an Observable to cache responses and you can't control the
3388
+ * subscribe/unsubscribe behavior of all the {@link Subscriber}s.
3389
+ * <p>
3390
+ * When you call {@code cache}, it does not yet subscribe to the source Observable and so does not yet
3391
+ * begin cacheing items. This only happens when the first Subscriber calls the resulting Observable's
3392
+ * {@code subscribe} method.
3393
+ * <p>
3383
3394
*
3384
- * @param capacity
3385
- * initial cache size
3395
+ * <em>Note:</em> You sacrifice the ability to unsubscribe from the origin when you use the {@code cache}
3396
+ * Observer so be careful not to use this Observer on Observables that emit an infinite or very large number
3397
+ * of items that will use up memory.
3398
+ * <p>
3399
+ * {@code cache} does not operate by default on a particular {@link Scheduler}.
3400
+ *
3401
+ * @warn description may be out-of-date
3402
+ * @param capacity hint for number of items to cache (for optimizing underlying data structure)
3386
3403
* @return an Observable that, when first subscribed to, caches all of its items and notifications for the
3387
3404
* benefit of subsequent subscribers
3388
3405
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#cache">RxJava Wiki: cache()</a>
0 commit comments