+ Start a Discussion
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11 

How does a session cache gets updated?

Hi,
we are implementing session cache for faster reloads. So I have theses following questions.

1.Lets say I have session cached an Account record and the account record is manually updated later by an Agent.
   In this scenario, how does the session cache gets updated.
2.what should be session cached and what should not?

Thanks in Advance,
Vijay
Best Answer chosen by Vijay Kumar Rebbala 11
NagendraNagendra (Salesforce Developers) 

Hi Vijay,

Please refer to 
http:// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_features.htm. 

The best data to cache is: reused throughout a session, static (not rapidly changing), otherwise expensive to retrieve. 

Caching a user field is not too expensive, but caching for, instance a value returned in the response of a third party's web service, or the result of running a Batch Apex job might be a good idea. The key is catching values that are not rapidly changing. 

Kindly mark this thread as solved if it's resolved so that experts from the community will not reply to this post which results in helping others.

Best Regards,
Nagendra.P


 

All Answers

NagendraNagendra (Salesforce Developers) 

Hi Vijay,

Please refer to 
http:// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_features.htm. 

The best data to cache is: reused throughout a session, static (not rapidly changing), otherwise expensive to retrieve. 

Caching a user field is not too expensive, but caching for, instance a value returned in the response of a third party's web service, or the result of running a Batch Apex job might be a good idea. The key is catching values that are not rapidly changing. 

Kindly mark this thread as solved if it's resolved so that experts from the community will not reply to this post which results in helping others.

Best Regards,
Nagendra.P


 
This was selected as the best answer
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11
we can put cache from Apex code using Cache.session.put. which cannot be used in a constructor.

Is there any work around to put a cache data from a constructor?
can we put cache from the Visualforcepage?

Thanks,
Vijay