コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Sling Model Caching

Avatar

Level 2

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?

1 受け入れられたソリューション

Avatar

正解者
Community Advisor

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://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/sling-models-caching-use-c...

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!

元の投稿で解決策を見る

1 返信

Avatar

正解者
Community Advisor

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://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/sling-models-caching-use-c...

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!