Git Product home page Git Product logo

Comments (20)

pavlospt avatar pavlospt commented on May 21, 2024

@tsaisean Can you also please post the get part of your code?

from store.

tsaisean avatar tsaisean commented on May 21, 2024

@pavlospt Updated.

from store.

pavlospt avatar pavlospt commented on May 21, 2024

@tsaisean And what version are you using?

from store.

tsaisean avatar tsaisean commented on May 21, 2024

@pavlospt I'm using the sample inside the Store project. "Store/app/src/"

from store.

pavlospt avatar pavlospt commented on May 21, 2024

@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.

pavlospt avatar pavlospt commented on May 21, 2024

screen shot 2017-03-07 at 11 49 22

It caches as expected. How did you check that it doesn't work on your case?

from store.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

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.

tsaisean avatar tsaisean commented on May 21, 2024

@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.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

Sure but when you say network is being called how do you see that?

from store.

tsaisean avatar tsaisean commented on May 21, 2024

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.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

Pls show me fetch being executed multiple times

from store.

tsaisean avatar tsaisean commented on May 21, 2024

image

Still waiting 5 secs for 2nd load since fetch is invoked again.

from store.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

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.

pavlospt avatar pavlospt commented on May 21, 2024

@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.

tsaisean avatar tsaisean commented on May 21, 2024

@pavlospt
Yes, I expected to get the value from memory cache directly for the 2nd onResume.

from store.

tsaisean avatar tsaisean commented on May 21, 2024

@digitalbuddha

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.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

Can you push your code to github I'll look in a few.

from store.

pavlospt avatar pavlospt commented on May 21, 2024

@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.

tsaisean avatar tsaisean commented on May 21, 2024

@pavlospt You are right! I'm blind. 😞

Thanks for your help! @pavlospt and @digitalbuddha
Very appreciated!! 🙂

from store.

digitalbuddha avatar digitalbuddha commented on May 21, 2024

#148 sample needs fixing

from store.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.