Hi All,
I'm trying to implement sling model caching in my project. I wanted to understand where the cached models are stored? Is there any specific dispatcher configuration required to implement sling model caching? Can we set a TTL for the cached models?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @H_Malhotra
What is the exact use case you have where you want to implement Sling model caching?
As per Sling documentation, By default, Sling Models do not do any caching of the adaptation result and every request for a model class will result in a new instance of the model class.
In general, it is strongly discouraged to store a reference to the original adaptable using the self injector. Using implementation version 1.4.8 or below, storing the original adaptable in a Sling Model, can cause heap space exhaustion, crashing the JVM. Starting in version 1.4.10, storing the original adaptable will not crash the JVM, but it can cause unexpected behavior (e.g. a model being created twice, when it should be cached). The issue was first reported in SLING-7586.
More details here:
https://sling.apache.org/documentation/bundles/models.html#caching
https://github.com/adobe/asset-share-commons/issues/177
Also here you do not have invalidate the cache as it's not cached in dispatcher.
Thanks!
Hi @H_Malhotra
What is the exact use case you have where you want to implement Sling model caching?
As per Sling documentation, By default, Sling Models do not do any caching of the adaptation result and every request for a model class will result in a new instance of the model class.
In general, it is strongly discouraged to store a reference to the original adaptable using the self injector. Using implementation version 1.4.8 or below, storing the original adaptable in a Sling Model, can cause heap space exhaustion, crashing the JVM. Starting in version 1.4.10, storing the original adaptable will not crash the JVM, but it can cause unexpected behavior (e.g. a model being created twice, when it should be cached). The issue was first reported in SLING-7586.
More details here:
https://sling.apache.org/documentation/bundles/models.html#caching
https://github.com/adobe/asset-share-commons/issues/177
Also here you do not have invalidate the cache as it's not cached in dispatcher.
Thanks!
Views
Likes
Replies