예제 #1
0
        /// <summary>
        /// Stores news items in the cache
        /// </summary>
        public static void SetCachedNews(List <NewsItem> news)
        {
            NewsCacheEntity entity = GetOrCreateEntity();

            entity.News = news;
            entity.Save(); // sets the UpdatedAt value to "now" automatically
        }
예제 #2
0
        /// <summary>
        /// Finds the cache entity in the database or creates and saves new one
        /// </summary>
        private static NewsCacheEntity GetOrCreateEntity()
        {
            var entity = DB.First <NewsCacheEntity>();

            if (entity == null)
            {
                entity = new NewsCacheEntity();
                entity.Save();
            }

            return(entity);
        }