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

Cache binding lookups for single bean providers #45

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

mcculls
Copy link
Contributor

@mcculls mcculls commented Jan 23, 2022

Previously every call to provider.get() for a Sisu-managed Provider<T> resulted in a new binding lookup.

These extra lookups are unnecessary because Sisu will automatically update live lookups as injectors come and go. This is done to support dynamic maps/lists of beans, but it does mean we can cache binding lookups and re-use them for single providers as long as we only get instances via BeanEntry.getProvider().get().

Note: we can't use BeanEntry.getValue() when re-using binding lookups because it caches the instance, whereas here we always want to return a fresh bean instance.

@mcculls mcculls merged commit c265d29 into master Jan 24, 2022
@mcculls mcculls deleted the mcculls/cacheBindingLookupsForSingleBeanProviders branch January 24, 2022 17:49
cstamas pushed a commit that referenced this pull request May 17, 2024
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

Successfully merging this pull request may close these issues.

1 participant