NET and C# and writing an application that retrieves data from a database. I have attempted to cache the database locally in an attempt to speed up the application when doing a search. I have used the following lines of code to retrieve and save the data from the database in cache.
cached_database = HttpRuntime.Cache.Get(cacheID) as Entities;
if (cached_database == null)
{
cached_database = InitializeDatabase(cacheID);
}
private Entities InitializeDatabase(string cacheID)
{
var database = this.database;
HttpRuntime.Cache.Insert(cacheID, database, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
return database;
}
I can see that I am able to return the correct cached data by looking at the debugger and the application still runs however it does not have any performance improvements. Am I doing this wrong, or is there possibility a better way to accomplish what I would like to do? Thanks.