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

CachedRolesProvider can be simplified #290

Open
alechenninger opened this issue Jul 3, 2017 · 1 comment
Open

CachedRolesProvider can be simplified #290

alechenninger opened this issue Jul 3, 2017 · 1 comment

Comments

@alechenninger
Copy link
Contributor

alechenninger commented Jul 3, 2017

@paterczm I think you may have written this, I have a small suggestion. I think you can replace the whole RolesCache class with a single instance of a Guava cache. The concept of a "fallback cache" is already implemented using refreshes: https://github.com/google/guava/wiki/CachesExplained#refresh

So instead of evicting entries after a fixed amount of time after a write, use refresh after that fixed amount of time and never evict otherwise. Refresh has the semantics you want: it will try to update with a more current value, even in the background (better!), as long as it can, otherwise it will keep the current value (that's your "fallback."). Then, using a cache loader, you can put your LDAP calls, and not have to manage putting/getting values manually.

@paterczm
Copy link
Contributor

paterczm commented Jul 4, 2017

Nice! Didn't know that. Next time.

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