public static UniResStoreLiteReader Get_URL_Reader(string store = "ShortResources") { string path = HttpContext.Current.Server.MapPath("~/App_Data/" + store + ".didxl"); UniResStoreLiteReader reader = HttpContext.Current.Cache[path] as UniResStoreLiteReader; if (reader == null) { lock (reader_init_lock) { reader = HttpContext.Current.Cache[path] as UniResStoreLiteReader; if (reader == null) { if (System.IO.File.Exists(path)) { reader = UniResStoreLiteReader.Load(path, CultureInfo.GetCultures(CultureTypes.NeutralCultures), true); CacheDependency dep = new CacheDependency(path); HttpContext.Current.Cache.Add(path, reader, dep, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), System.Web.Caching.CacheItemPriority.Normal, ReaderRemovedCallback); } } } } return(reader); }
private static void ReaderRemovedCallback(string key, object val, CacheItemRemovedReason reason) { UniResStoreLiteReader reader = val as UniResStoreLiteReader; reader.ShutDown(); }