[
https://issues.apache.org/jira/browse/SLING-11074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dirk Rudolph resolved SLING-11074.
----------------------------------
Resolution: Won't Fix
> Cache model for all of its adapter types
> ----------------------------------------
>
> Key: SLING-11074
> URL: https://issues.apache.org/jira/browse/SLING-11074
> Project: Sling
> Issue Type: Improvement
> Components: Sling Models
> Reporter: Dirk Rudolph
> Assignee: Dirk Rudolph
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Currently the ModelAdapterFactory caches a cacheable model for the requested
> type only
> https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L430-L432
> {code}
> if (result.wasSuccessful() && modelAnnotation.cache() && adaptableCache !=
> null) {
> adaptableCache.put(requestedType, new
> SoftReference<Object>(result.getValue()));
> }
> {code}
> However, if a model is an adapter of multiple types an instance of it can
> also be returned for more than just the requested type.
> Caching the model for each of its adapter types may improve the cache hit
> ratio.
> {code}
> interface A {}
> interface B {}
> @Model(cache=true, adaptables=Resource.class, adapters={A.class, B.class})
> class Model implements A, B {}
> assertSame(givenResource.adaptTo(A.class), givenResource.adaptTo(B.class))
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)