Comments (7)
Top of the morning! Could you try with a non empty barcode. Also are you using the latest version, there was a missing hash code previously. The way the functionality is expected to work: memory caching is done in a Guava LoadingCache which backs each store. If multiple requests are made to the same mem cache, the loader will block each subsequent request until a single result is made. I'll validate if a bug. Thanks for reporting
from store.
Same with non-empty barcodes. Tested with be47cff
Adjusted the provided testcase above.
from store.
Thanks for reporting. Will look at it today. I'm curious why StoreTest.testDoubleTap is passing yet this is not. Yay for more tests
from store.
Hey 1 more request. Could you please convert the test case to Java. I want to make sure I test against exactly what is failing for you
from store.
Can't you add kotlin for tests? Java is such a pain
import com.nytimes.android.external.store.base.Store;
import com.nytimes.android.external.store.base.impl.BarCode;
import com.nytimes.android.external.store.base.impl.StoreBuilder;
import org.junit.Before;
import org.junit.Test;
import rx.Observable;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Paul Woitaschek
*/
public class SequentialTest {
private int networkCalls = 0;
private Store<Integer> store;
@Before
public void setup() {
networkCalls = 0;
store = StoreBuilder.<Integer>builder()
.fetcher(barCode -> Observable.fromCallable(() -> networkCalls++))
.open();
}
@Test
public void sequentially() {
BarCode b = new BarCode("one", "two");
store.get(b).test().awaitTerminalEvent();
store.get(b).test().awaitTerminalEvent();
assertThat(networkCalls).isEqualTo(1);
}
@Test
public void parallel() {
BarCode b = new BarCode("one", "two");
Observable<Integer> first = store.get(b);
Observable<Integer> second = store.get(b);
first.test().awaitTerminalEvent();
second.test().awaitTerminalEvent();
assertThat(networkCalls).isEqualTo(1);
}
}
from store.
you nailed it.
This is because you immediately call
Wrapped the call in a defer and tests pass. Thank you for using (and finding) issues within the Store. LMK if ever in nyc, I owe you a beer (and a visit to ny times if you'd like)
from store.
Ok so you're find actually surfaced a few issues. Here is another one: The disk cache was not lazy. Internally this was fine for us, but for you without a disk cache the No-Op disk cache internally was immediately encoding a cache miss within the parallel test. TIL I should write more tests :-) another pr coming
from store.
Related Issues (20)
- Store 4 design document HOT 2
- Observe changes in disk without invalidating cache HOT 2
- NetworkOnMainThread thrown when performing a clear from the MainThread HOT 1
- Question: Convert List<T> From API to BufferedSource
- Question: Shouldn't Persister.write return single which will write to cache only after subscribe? HOT 2
- Sample crashes on launch
- Get data always hits the network without persister HOT 5
- Clear FileSystemPersister HOT 1
- Support for partial fetches (for paginated APIs) HOT 1
- Clearable HOT 2
- Feature Request : support for multiple get/fetch HOT 1
- RecordPersister's 'Expiration' is not working HOT 8
- Misleading docs and behavior of Store.clear() HOT 6
- How to determine if a key is in memory cache? HOT 3
- fetchWithResult returns NETWORK even on network errors HOT 2
- Issue with gradle plugin 3.4.0 HOT 11
- Provide a method for getting data from memory cache
- Having trouble fetching data using android nytimes store library HOT 1
- Request is made multiple times
- This library seems to be deprecated. Other alternatives? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from store.