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 cache a singleton instance in a subscope of a binding? #434

Open
macabrus opened this issue Apr 16, 2022 · 0 comments
Open

How to cache a singleton instance in a subscope of a binding? #434

macabrus opened this issue Apr 16, 2022 · 0 comments

Comments

@macabrus
Copy link

Suppose I am building a Web server. I tried to organize my scopes as such:

AppScope -> SessionScope -> RequestScope -> MyScope

How would I go about binding singleton instances to last scope and not to the scope where they were installed?
My motivation for such approach is performance. Suppose there are a lot of bindings in RequestScope that need to be installed (say thousands), but very few of them are ever used. It would be very expensive to install those bindings on every request when they are not needed. If I could just install them once but instantiate them in subscope that would be great!

So I'd like to resolve those few instances and cache them during request in MyScope. However, current behavior is that RequestScope caches them and I am stuck. I tried playing with supportScopeAnnotations without luck.

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

1 participant