コード例 #1
0
        /// <summary>
        /// gets the cache of the member
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private static NewsCache GetCache()
        {
            try
            {
                NewsCache dataObject = (NewsCache)HttpContext.Current.Cache["NewsCache"];
                if (dataObject == null)
                {
                    lock (ThisLock)
                    {
                        dataObject = (NewsCache)HttpContext.Current.Cache["NewsCache"];

                        if (dataObject == null)
                        {
                            dataObject = new NewsCache();
                            XmlFileSystemProvider pr = new XmlFileSystemProvider();
                            var dir111 = BlogService.GetDirectory("~/");
                            dataObject.PictureArchive = pr.GetAllImages(dir111).ToList();
                            HttpContext.Current.Cache["NewsCache"] = dataObject;
                        }
                    }
                }
                return dataObject;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }
コード例 #2
0
 public static NewsCache UpdateCache(NewsCache newsCache)
 {
     try
     {
         lock (ThisLock)
         {
             HttpContext.Current.Cache["NewsCache"] = newsCache;
         }
         return newsCache;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return null;
 }