Dirk Rudolph created SLING-11074: ------------------------------------ Summary: 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
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 it can also be returned for more than just the requested type. Caching the model for each of the 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)