Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
Currently the ModelAdapterFactory caches a cacheable model for the requested type only
if (result.wasSuccessful() && modelAnnotation.cache() && adaptableCache != null) { adaptableCache.put(requestedType, new SoftReference<Object>(result.getValue())); }
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.
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))