Store icon indicating copy to clipboard operation
Store copied to clipboard

Is there a way to only clear memory cache?

Open saket opened this issue 6 years ago • 10 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?

saket avatar Mar 20 '18 16:03 saket

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

wdziemia avatar Mar 20 '18 16:03 wdziemia

Cool, thanks!

saket avatar Mar 20 '18 18:03 saket

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.

dbof10 avatar Mar 29 '18 08:03 dbof10

I think we should label as bug

dbof10 avatar Mar 29 '18 08:03 dbof10

There is an open PR for this https://github.com/NYTimes/Store/pull/322

pavlospt avatar Mar 29 '18 09:03 pavlospt

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 avatar Mar 29 '18 11:03 digitalbuddha

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

saket avatar Mar 29 '18 13:03 saket

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.

digitalbuddha avatar Mar 29 '18 13:03 digitalbuddha

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.

saket avatar Mar 29 '18 14:03 saket

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 :-)

digitalbuddha avatar May 25 '18 14:05 digitalbuddha