Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

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?

adobecq-venkat
Level 3
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
BrianKasingli
Correct answer by
Community Advisor
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
BrianKasingli
Correct answer by
Community Advisor
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