nytimes / Store

Android Library for Async Data Loading and Caching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request is made multiple times

marcin-adamczewski opened this issue · comments

Hi,

I'm testing your library and have noticed that when store.get() is called multiple times in the same time, then the request is made also multiple times, despite having either memory cache or persister.

Steps to reproduce using sample app:

  1. Open PersistingStoreActivity
  2. Change persistedStore.get() method to
persistedStore
                .getWithResult(awwRequest)
                .map(result -> {
                    Log.d("lol", result.source().toString());
                    return result.value();
                })

In order to see the source.
3. In onResume() method call loadPosts(); method multiple times instead of one time.
4. Logs prints NETWORK multiple times.

Make sure to make a clean app install as there is a persister added or remove persister and add memory cache.
I've noticed that inFlightRequests didn't cache the first Single.

PS I had to change baseUrl to .baseUrl("https://reddit.com/") for sample app to work on Android 8 as it required https instead of http.