To improve performance a caching mechanism can be used to store objects in memory
and eliminate redundant round trips to the data source.
The class ManagingEnergy.Data.Caching.CachedAdaptor has been included within the API to perform this function.
It adds a caching layer to any existing implementation of IManagingEnergyDataAdaptor. All data operations are passed to the underlying IManagingEnergyDataAdaptor and are cached for future requests.
The constructor accepts two parameters. The first is an instance of an IManagingEnergyDataAdaptor which will act as the underlying data source. The second is a cache instance.
// Create an instance of the MSSQL implementation of the IManagingEnergyDataAdaptor ManagingEnergy.Data.IManagingEnergyDataAdaptor sqlDataAdaptor = new ManagingEnergy.Data.MSSQL.SqlAdaptor("Data Source=sqlserver;Integrated Security=True;");
// Create an instance of the cached implementation of the IManagingEnergyDataAdaptor ManagingEnergy.Data.IManagingEnergyDataAdaptor cachedAdaptor = new ManagingEnergy.Data.Caching.CachedAdaptor(sqlDataAdaptor, new ManagingEnergy.Caching.WebCache(TimeSpan.FromMinutes(5))); |