The simple answer is RecordViewCache class. This class is used to implement set-based caching in your code at run-time.
1. First declare the variables.
2 . Call a nofetch query to create a record buffer. It will define the set of records that you want to cache.
//Define records to cache
select nofetch custTrans
where custTrans.AccountNum == ‘4000’;
3. Pass the record buffer to instantiate RecordViewCache Object. It will also cache the records that are returned in the buffer.
recordViewCache = new RecordViewCache(custTrans);
4. The records in the following query will be returned from the cache.
select firstOnly custTrans where custTrans.AcccountNum == ‘4000’ &&
custTrans.CurrencyCode == ‘USD’;