Skip to content

Cache binding lookups for single bean providers#45

Merged
mcculls merged 2 commits intomasterfrom
mcculls/cacheBindingLookupsForSingleBeanProviders
Jan 24, 2022
Merged

Cache binding lookups for single bean providers#45
mcculls merged 2 commits intomasterfrom
mcculls/cacheBindingLookupsForSingleBeanProviders

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