/// <summary> /// Get /// </summary> /// <returns></returns> public IEnumerable <ToDoItem> GetCachedToDoItems() { IEnumerable <ToDoItem> toDoItems; _cache.TryGetValue <IEnumerable <ToDoItem> >(CacheHelpers.GenerateToDoItemsCacheKey(), out toDoItems); return(toDoItems); }
/// <summary> /// Set /// </summary> /// <param name="entry"></param> public void SetCachedToDoItems(IEnumerable <ToDoItem> entry) { // Set cache options var cacheEntryOptions = new MemoryCacheEntryOptions() // Keep in cache for this time, reset time if accessed. .SetSlidingExpiration(TimeSpan.FromDays(1)); _cache.Set(CacheHelpers.GenerateToDoItemsCacheKey(), entry, cacheEntryOptions); }
/// <summary> /// Delete /// </summary> /// <returns></returns> public void DeleteCachedToDoItems() { _cache.Remove(CacheHelpers.GenerateToDoItemsCacheKey()); }
/// <summary> /// Delete /// </summary> /// <returns></returns> public void DeleteCachedToDoItems() { // TODO : when deleting an ToDoItem, trigger an event to remove cached item. _cache.Remove(CacheHelpers.GenerateToDoItemsCacheKey()); }