/// <summary> /// Returns all event calendars /// </summary> /// <returns></returns> public static List <EventCalendarCache> All() { List <EventCalendarCache> eventCalendars = new List <EventCalendarCache>(); var eventCalendarIds = GetOrAddExisting("Rock:EventCalendar:All", () => LoadAll()); if (eventCalendarIds != null) { foreach (int eventCalendarId in eventCalendarIds) { eventCalendars.Add(EventCalendarCache.Read(eventCalendarId)); } } return(eventCalendars); }
/// <summary> /// Removes event calendar from cache /// </summary> /// <param name="id"></param> public static void Flush(int id) { FlushCache(EventCalendarCache.CacheKey(id)); FlushCache("Rock:EventCalendar:All"); }
/// <summary> /// Adds EventCalendar model to cache, and returns cached object /// </summary> /// <param name="eventCalendarModel"></param> /// <returns></returns> public static EventCalendarCache Read(EventCalendar eventCalendarModel) { return(GetOrAddExisting(EventCalendarCache.CacheKey(eventCalendarModel.Id), () => LoadByModel(eventCalendarModel))); }
/// <summary> /// Returns EventCalendar object from cache. If event calendar does not already exist in cache, it /// will be read and added to cache /// </summary> /// <param name="id">The identifier.</param> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public static EventCalendarCache Read(int id, RockContext rockContext = null) { return(GetOrAddExisting(EventCalendarCache.CacheKey(id), () => LoadById(id, rockContext))); }