Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Wanted to read jcr and make the data available on back-end. Kind of caching the data on backend. Is there an object like aemcontext or server context?

Avatar

Level 3

Wanted to read jcr and available to all the components. Is there an object like aemcontext or server context?

 

I wanted to store the data until the server is down/restarted.

In Java sever side, servletxcontext can hold the data and available to all the servlets with access to servletcontext.

I tried the same in AEM, it didnt work.

Please suggest if any such object available which holds the data in the back end.It is like caching.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

How are you using the data stored in the JCR? Assuming that the cached data is exposed via JSON, you can try this strategy.

 

In AEM 6.5, it's suggested that all content should live within the /content folder structure. Knowing this is the case when you are creating a caching strategy with your sling servlet, you can write cached data directly into the /content structure with the servlet validating an expiry date against the target root node. When the criteria are met, then you can re-write and re-publish the /content structure.

 

When deactivating your servlet, you can write some logic to wipe out the data stored in your designated structured data store:

 

 
protected void deactivate() {
 cleanup();
}

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

How are you using the data stored in the JCR? Assuming that the cached data is exposed via JSON, you can try this strategy.

 

In AEM 6.5, it's suggested that all content should live within the /content folder structure. Knowing this is the case when you are creating a caching strategy with your sling servlet, you can write cached data directly into the /content structure with the servlet validating an expiry date against the target root node. When the criteria are met, then you can re-write and re-publish the /content structure.

 

When deactivating your servlet, you can write some logic to wipe out the data stored in your designated structured data store:

 

 
protected void deactivate() {
 cleanup();
}