question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to clear/disable selector cache

See original GitHub issue

There’s some cases where you don’t want responses to be cached, because they depend on the currently logged-in user. If the user logs out, it’s a security issue for their data to be cached. It would be good to have some way to clear the cached values on log out.

What’s the recommended way to handle this situation?

export const selector_user_first_name = selector<string>({
    key: 'user_first_name',
    get: async () => {
        return await (await fetch('/User/FirstName')).text();
    }
});

export const LogOut = () => {
    await fetch('/User/Logout', { method: 'POST' });
    clearSelector(selector_user_first_name );
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
drarmstrcommented, Apr 23, 2021

@csantos42 is working on exactly this.

3reactions
florianbepunktcommented, Aug 6, 2021

@drarmstr Selector cache policies do not fully address this issue. As far as I can tell from the docs, it is not possible to disable or imperatively clear a cache. We have some unit tests where cached selector data is bleeding between tests (see issue https://github.com/facebookexperimental/Recoil/issues/981)

There is no cache strategy of “none”. Also a cache strategy of { eviction: 'lru', maxSize: 0 } does not disable caching.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Magento 2 Clear Cache: How to Flush, Enable and Disable ...
Go to System · Access Cache Management · Select all unnecessary cache types · Open the Actions drop-down menu (on the left) ·...
Read more >
Turn on Cached Exchange Mode - Microsoft Support
Cached Exchange Mode is the default when you add an Exchange or Microsoft 365 ... Exchange Mode, repeat the steps, but clear Use...
Read more >
Disabling Chrome cache for website development
The Chrome DevTools can disable the cache. Right-click and choose Inspect Element to open the DevTools. Or use one of the following keyboard...
Read more >
How to Clear Your Cache in WordPress (Step by Step)
Simply go to Settings » WP Super Cache in your WordPress admin dashboard, and then click the 'Delete Cache' button in the 'Delete...
Read more >
How to Clear Cache for All Major Browsers - Kinsta
However, many situations warrant the clearing of all cache data. In Chrome, select the Advanced tab in the Clear browsing data window. Now,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found