Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to keep cache isolated between different users ? #112

Closed
fasidOnGit opened this issue Aug 3, 2021 · 5 comments
Closed

How to keep cache isolated between different users ? #112

fasidOnGit opened this issue Aug 3, 2021 · 5 comments

Comments

@fasidOnGit
Copy link

Let us consider the following method

@Cacheable()
  getOrders() {
    return this.http
    .get(`${environment.api}/orders`);
  }

If I switch users in the same machine in the same window (like logout and login). I see that the cache from the previous user is used for the currently logged-in user. which yields me totally wrong set of values.

I also tried to set the globalCacheKey to be a unique id to isolate the cache between multiple users. But it doesn't work.

Thanks in advance.

@fasidOnGit
Copy link
Author

globalCacheKey is partially fixing the issue. It does create unique entries in localStorage, But when I change the value of globalCacheKey again, it doesn't create a new entry for that in localStorage rather, still use the old one. is it intended ?

@angelnikolov
Copy link
Owner

Hey @fasidOnGit, I think this should be left to user land since we cant make any assumptions on when and how to clear the cache.
The global cache key is just for the purposes of name-spacing your cache storage.

@fasidOnGit
Copy link
Author

The global cache key is just for the purposes of name-spacing your cache storage.

That only works during the app bootstrap. switching reactively between cache key looks like not possible.

@angelnikolov
Copy link
Owner

Correct, it only works once. For further separation you'd likely create your own storage strategy which switches between multiple namespaces

@fasidOnGit
Copy link
Author

Alright, thanks for the explanation.

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

No branches or pull requests

2 participants