Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Misleading docs and behavior of Store.clear() #377

Open
bobymicroby opened this issue Jan 30, 2019 · 6 comments
Open

Misleading docs and behavior of Store.clear() #377

bobymicroby opened this issue Jan 30, 2019 · 6 comments

Comments

@bobymicroby
Copy link

Store.clear() claims that it will purge all entries from memory and disk cache

     /**
     * purges all entries from memory and disk cache
     * Persister will only be cleared if they implements Clearable
     */
    void clear();

But in fact it only clears from the disk the entries that are currently in the memory cache.

    @Override
    public void clear() {
        for (Key cachedKey : memCache.asMap().keySet()) {
            clear(cachedKey);
        }
    }

If you call this method after a cold start, nothing will be purged from disk, leaving many entries roaming around the disk without a pointer.

@digitalbuddha
Copy link
Contributor

Yeah that's pretty crappy. I never found a good way to fix it. One solution is to delegate responsibility to a user's persister by calling clear. Alternatively a store can be stateful which is hard without storage. Open to suggestions 🤔

@bobymicroby
Copy link
Author

bobymicroby commented Jan 30, 2019

First thing that comes to mind

image

And on clear() we check if the resolver is the proper instance and if so, we delete the directory :)

P.S I know that this is pretty lame, and there are a lot of things to consider.
When I can find the time i will give it a proper thought and hopefully will come to a nice solution.
Cheers !

@digitalbuddha
Copy link
Contributor

That looks reasonable. I'll think about it as well.

@mradzinski
Copy link

Any news regarding this? My use case is quite simple: Need to clean entries from disk when a user logs out. It certainly would be nice to be able to purge all entries without having to resort on "hacks", like setting a different type per user to force re-fetching when types don't match...

@digitalbuddha
Copy link
Contributor

We are working on new version. It will have a better handle for this. Not sure release date

@bobymicroby
Copy link
Author

@mradzinski @digitalbuddha I've implemented POC that works based on my proposal above. Tried it in prod in my last app, living on the edge and stuff, and didn't find time to polish it to good PR. Shame.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants