I'm looking to improve performance by using some king of cache. For example users login and access an appointment system, I would like to Cache this data, query this data from the cache and then update the cache should new appointments be added
For example, I was writing this but I think this is application caching and not session (dont want other users seeing other peoples data)
public IEnumerable<ScheduledItem> GetCache(bool reload, DateTime start, DateTime end, Account account)
{
if (System.Web.HttpContext.Current.Cache["ScheduleData"] == null)
{
var model = _eventService.FindAllEventsForAccountId(account.Id, start.Date, end.Date)
.Where(IsAppointmentNotCancelled)
.Select(a => new Models.ScheduledItem()
{
id = a.Id,
start = a.StartTime.ToString("H:mm:ss").Length < 8 ? string.Format(a.StartTime.ToString("yyyy-MM-dd {0}H:mm:ss"), 0) : a.StartTime.ToString("yyyy-MM-dd H:mm:ss"),
end = a.EndTime.ToString("H:mm:ss").Length < 8 ? string.Format(a.EndTime.ToString("yyyy-MM-dd {0}H:mm:ss"), 0) : a.EndTime.ToString("yyyy-MM-dd H:mm:ss"),
backgroundColor = GetColour(a),
title = GetTitle(a, account),
textColor = "#fff",
AppointmentType = GetType(a),
resourceId = GetResource(a)
}).ToList();
return model;
}
return null;
}
Any pointers, examples would be great