nytimes / Store

Android Library for Async Data Loading and Caching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to only clear memory cache?

saket opened this issue · comments

If I'm not wrong, there is no way to clear only the memory cache. clearMemory() is deprecated so this looks like an intentional behavior. I was hoping to clear my memory cache when ComponentCallbacks2#onTrimMemory() gets called. Is there any way to do this?

Currently no, but we are actively looking into a solution to allow this, whether automated via ComponentCallbacks2 or manual. We will keep you posted! 🙂

Cool, thanks!

I think clear memory is an important feature. I get data for UserA when log into UserB I get stale data from UserA even though I try to call clear but that doesn't work.

I think we should label as bug

There is an open PR for this #322

That pr is not related to clearing more. Clear memory was Deprecated because clear now clears only memory unless you have a Persister that implements Clearable. Pls use clear as though it is clear memory.

@digitalbuddha but what if I only want to clear memory and not disk even if I have a Clearable persister?

Could you kindly give a use case for wanting to clear memory and not disk sometimes but wanting to clear memory and disk other times for same store.

The same thing I mentioned in my original post. If I receive a callback from the system that the phone is running low on memory (onTrimMemory()), I'd like to clear my memory cache.

open to a pr if you'd like, I'm not crazy about it but will take the contribution if someone else wants to do the work :-)