I'm using LINQ to SQL to call some reporting stored procedures.
Each stored procedure returns a class which accepts some input parameters, for example:
public partial class csp_WeekCommencingListResult
{
public static IEnumerable<csp_WeekCommencingListResult> GetAll(int? masterTrackingGroupId)
{
using (var dataContext = OscaDataContext.CreateWithCustomTimeOut())
{
return dataContext
.csp_WeekCommencingList(masterTrackingGroupId)
开发者_如何转开发 .ToList();
}
}
}
How could I cache the result of the stored procedure for the passed parameters?
For example, when 1 is passed to this stored procedure, its result should be cached for a day.
Any thoughts? is there any framework I can use? or I have to build my own custom cache manager per stored procedure using the .NET Cache object?
Thanks,
You should probably add caching at a higher level, for example in the code that is calling this code.
Try to figure out a good caching strategy that works with your project.
And when it comes to cache managers, I usually use the ICacheManager
from Microsoft EnterpriseLibrary Caching which I property inject with some dependency injection framework like Castle or StructureMap. That way I can run different configurations for different environments (dev, test, prod etc).
精彩评论