[Authenticate]
public class OrgYesterdaySnapshotService : Service
{
public object Any(OrgYesterdaySnapshot request)
{
if (!request.Dt.HasValue)
request.Dt = DateTime.Today;
return base.Request.ToOptimizedResultUsingCache<OrgYesterdaySnapshot>(
base.Cache, request.CacheKey, CacheExpiryTime.DailyLoad(), () =>
{
return OrgYesterdaySnapshotFactory.GetObject(request, SessionAs<DVAuthUserSession>().UserName);
});
}
}
Sample service above. Wondering if there’s a common coding pattern to prevent putting an object in the cache if there was some type of Exception in the Factory class. We’re running into an issue where a temporal error (like a database timeout) causes an object to load incorrectly. In those instances, I don’t want to load the object into the cache (let the next caller re-run the factory and hopefully get a read object, which is then the one that hits the cache).