RxCache icon indicating copy to clipboard operation
RxCache copied to clipboard

How do I update the cache without calling Retrofit?

Open AungThiha opened this issue 8 years ago • 3 comments

AungThiha avatar Feb 06 '18 08:02 AungThiha

yes, recently i have facing the same situation cuz i want to clear user account information without calling retrofit again. May I ask for any method to do so?

darylsze avatar Feb 14 '18 09:02 darylsze

you have to evict the previous cached data, to do that, supply to the provider any dummy observable with an empty list or whatever representation that typified your "empty state".

An example:

getMocksFilteredEvict(Observable.just(emptyList()), new DynamicKey("yourKey"), new EvictDynamicKey(true)
	.subscribe()

If you want a more flexible approach, use ReactiveCache

VictorAlbertos avatar Feb 14 '18 15:02 VictorAlbertos

Dear author, I have tried to follow your method, such as the following code is my attempt.The result is that the data in the data field in the cache is set to empty.But once again, when I read the cache of the API, he returned the empty data directly to me without asking for new data.If I need new data, I must manually refresh it.Before that I thought that if I read an empty cache, I would automatically refresh the data.Is there any misunderstanding about how I use it?

Observable observable = Observable.just(new ArrayList());       
RequestFactory.getStartCacheRequest().testCacheForOneClear(observable, new EvictProvider
                (true)).subscribe();

qianshengta avatar May 23 '18 10:05 qianshengta