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

Avatar

adobecq-venkat

Avatar

adobecq-venkat

adobecq-venkat

16-03-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

BrianKasingli

MVP

Avatar

BrianKasingli

MVP

BrianKasingli
MVP

10-08-2020

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();
}

 

Answers (0)