Comments (20)
@tsaisean Can you also please post the get
part of your code?
from store.
@pavlospt Updated.
from store.
@tsaisean And what version are you using?
from store.
@pavlospt I'm using the sample inside the Store project. "Store/app/src/"
from store.
@tsaisean Did you delete the persister or something like that? The first time it is supposed to request from Network due to a cache miss, but the second time it will hit your cache.
from store.
It caches as expected. How did you check that it doesn't work on your case?
from store.
Hi thank you for submission but we have to trouble reproducing problem. Could you include a failing test case that shows network getting hit on multiple calls.
from store.
@pavlospt @digitalbuddha
I'm using StoreActivity, not PersistingStoreActivity.
/Store/app/src/main/java/com/nytimes/android/sample/activity/StoreActivity.java
I intended to use memory cache only, and no disk cache.
from store.
Sure but when you say network is being called how do you see that?
from store.
I didn't say network. I modify the sample a bit. 😄
private Store<Integer, BarCode> provideRedditStore() {
return StoreBuilder.<Integer>barcode()
.fetcher(new Fetcher<Integer, BarCode>() {
@Nonnull
@Override
public Observable<Integer> fetch(@Nonnull BarCode barCode) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return Observable.just(5);
}
})
.open();
}
from store.
Pls show me fetch being executed multiple times
from store.
Still waiting 5 secs for 2nd load since fetch
is invoked again.
from store.
Do me a favor. Make fetch return i++ so value changes each time it is executed. I'll be at work in hour and can see what's up then.
from store.
@tsaisean When do you call the Store.get()
method? As I see from your screenshot seems like you are sending the app on background and call .get()
in onResume()
?
from store.
@pavlospt
Yes, I expected to get the value from memory cache directly for the 2nd onResume
.
from store.
03-07 08:44:26.743 27674-27674/com.nytimes.android.sample D/StoreActivity: onResume
03-07 08:44:26.743 27674-27674/com.nytimes.android.sample D/StoreActivity: [loadPosts] start
03-07 08:44:26.743 27674-27674/com.nytimes.android.sample D/StoreActivity: [loadPosts] Call provideRedditStore get with key "aww"
03-07 08:44:31.817 27674-27751/com.nytimes.android.sample D/StoreActivity: [fetch] return 1
03-07 08:44:31.823 27674-27674/com.nytimes.android.sample D/StoreActivity: [onNext] get 1
03-07 08:44:31.823 27674-27674/com.nytimes.android.sample D/StoreActivity: [onCompleted]
03-07 08:44:41.555 27674-27674/com.nytimes.android.sample D/StoreActivity: onResume
03-07 08:44:41.555 27674-27674/com.nytimes.android.sample D/StoreActivity: [loadPosts] start
03-07 08:44:41.555 27674-27674/com.nytimes.android.sample D/StoreActivity: [loadPosts] Call provideRedditStore get with key "aww"
03-07 08:44:46.556 27674-27751/com.nytimes.android.sample D/StoreActivity: [fetch] return 2
03-07 08:44:46.557 27674-27674/com.nytimes.android.sample D/StoreActivity: [onNext] get 2
03-07 08:44:46.557 27674-27674/com.nytimes.android.sample D/StoreActivity: [onCompleted]
from store.
Can you push your code to github I'll look in a few.
from store.
@tsaisean I think I know why this is happening! Well, since you are using the sample app, it means that each time you call loadPosts()
you create a new Store
object. What this does is create it from scratch and then give it back so you can call .get()
. Even if you added a memory caching there, it would still not work.
What you need to do is: 1) Create a class variable and instantiate Store
. When you are going to use it, check if it is already null and instantiate it. 2) Use the class variable to call .get()
on instead of the method.
from store.
@pavlospt You are right! I'm blind. 😞
Thanks for your help! @pavlospt and @digitalbuddha
Very appreciated!! 🙂
from store.
#148 sample needs fixing
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.