I have one method from which i am calling onother method which is having soql query. Every time method calls .Soql will get executed.to avoid any performance issue i have created session.catche code
public class HandlerClass () {
public static vod getdata(string recordId) {
boolean falg = getAccount(recordId)
}
public static boolean getAccount(string recordId) {
List<Account> acc= [select id from account where id=:recordsids limit 1];
if(acc.size()>0)
return true
else
return false
}
}
// Get partition
Cache.SessionPartition sessionPart = Cache.Session.getPartition('local.AccountCache');
// Add cache value to the partition
List<account> lst= new List<account>([select id from account]);
system.debug(lst);
sessionPart.put('accData', lst);
// Retrieve cache value from the partition
lst = new List<account>();
lst = (List<account>)sessionPart.get('accData');
system.debug(lst);
But i am not sure where to save this code .and how to refer in getdata method to avoid soql query everytime