Hi Ajay,
Yes you can use static variables for this as they are meant for same purpose .
Create a static list in your helper class and use same in your before trigger and after trigger
public class cachequery {
public static List<Account> lstaccount= [Select Id,Name from Account LIMIT 10];
}
The sample trigger to provide an idea
trigger T1 on Account (before insert, after insert) {
list<Account> lstcached = cachequery.lstaccount;
if(Trigger.isBefore && Trigger.isInsert){
system.debug(lstcached );
}
if(Trigger.isAfter && Trigger.isInsert){
system.debug(lstcached );
}
}
Hope this helps you.