/// <summary> /// Initializes a new instance of the <see cref="DNNCacheDependency"/> class that monitors an array of paths (to files or directories), /// an array of cache keys, or both for changes. /// It also makes itself dependent upon another instance of the <see cref="DNNCacheDependency"/> class and a time when the change monitoring begins. /// </summary> /// <param name="filenames">The filenames.</param> /// <param name="cachekeys">The cachekeys.</param> /// <param name="dependency">The dependency.</param> /// <param name="start">The start.</param> public DNNCacheDependency(string[] filenames, string[] cachekeys, DNNCacheDependency dependency, DateTime start) { _utcStart = start.ToUniversalTime(); _fileNames = filenames; _cacheKeys = cachekeys; _cacheDependency = dependency; }
public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { //onRemoveCallback += ItemRemovedCallback; //Call base class method to add obect to cache base.Insert(cacheKey, itemToCache, dependency, absoluteExpiration, slidingExpiration, priority, onRemoveCallback); }
//Method that does the actual disposal of resources protected virtual void Dispose(bool disposing) { if ((disposing)) { if (_cacheDependency != null) { _cacheDependency.Dispose(disposing); } if (_systemCacheDependency != null) { _systemCacheDependency.Dispose(); } _fileNames = null; _cacheKeys = null; _cacheDependency = null; _systemCacheDependency = null; } }
// Method that does the actual disposal of resources protected virtual void Dispose(bool disposing) { if (disposing) { if (this._cacheDependency != null) { this._cacheDependency.Dispose(disposing); } if (this._systemCacheDependency != null) { this._systemCacheDependency.Dispose(); } this._fileNames = null; this._cacheKeys = null; this._cacheDependency = null; this._systemCacheDependency = null; } }
public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { //initialize cache dependency DNNCacheDependency d = dependency; //if web farm is enabled if (IsWebFarm()) { //get hashed file name var f = new string[1]; f[0] = GetFileName(cacheKey); //create a cache file for item CreateCacheFile(f[0], cacheKey); //create a cache dependency on the cache file d = new DNNCacheDependency(f, null, dependency); } //Call base class method to add obect to cache base.Insert(cacheKey, itemToCache, d, absoluteExpiration, slidingExpiration, priority, onRemoveCallback); }
public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { //initialize cache dependency DNNCacheDependency d = dependency; //if web farm is enabled if (IsWebFarm()) { //get hashed file name var f = new string[1]; f[0] = GetFileName(cacheKey); //create a cache file for item CreateCacheFile(f[0], cacheKey); //create a cache dependency on the cache file d = new DNNCacheDependency(f, null, dependency); } //Call base class method to add obect to cache base.Insert(cacheKey, itemToCache, d, absoluteExpiration, slidingExpiration, priority, onRemoveCallback); }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The value.</param> /// <param name="dependency">The dependency.</param> /// <param name="absoluteExpiration">The absolute expiration.</param> /// <param name="slidingExpiration">The sliding expiration.</param> /// <param name="priority">The priority.</param> /// <param name="onRemoveCallback">The on remove callback.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { Cache.Insert(cacheKey, itemToCache, dependency == null ? null : dependency.SystemCacheDependency, absoluteExpiration, slidingExpiration, priority, onRemoveCallback); }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The object.</param> /// <param name="dependency">The dependency.</param> /// <param name="absoluteExpiration">The absolute expiration.</param> /// <param name="slidingExpiration">The sliding expiration.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration) { Insert(cacheKey, itemToCache, dependency, absoluteExpiration, slidingExpiration, CacheItemPriority.Default, null); }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The object.</param> /// <param name="dependency">The dependency.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency) { Insert(cacheKey, itemToCache, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, null); }
public static NameValueCollection GetTimeZones(string language) { language = language.ToLower(); string cacheKey = "dotnetnuke-" + language + "-timezones"; string translationFile; if (language == SystemLocale.ToLower()) { translationFile = TimezonesFile; } else { translationFile = TimezonesFile.Replace(".xml", "." + language + ".xml"); } var timeZones = (NameValueCollection)DataCache.GetCache(cacheKey); if (timeZones == null) { string filePath = HttpContext.Current.Server.MapPath(translationFile); timeZones = new NameValueCollection(); if (File.Exists(filePath) == false) { return timeZones; } var dp = new DNNCacheDependency(filePath); try { var d = new XmlDocument(); d.Load(filePath); foreach (XmlNode n in d.SelectSingleNode("root").ChildNodes) { if (n.NodeType != XmlNodeType.Comment) { timeZones.Add(n.Attributes["name"].Value, n.Attributes["key"].Value); } } } catch (Exception exc) { Logger.Error(exc); } if (Host.PerformanceSetting != Globals.PerformanceSettings.NoCaching) { DataCache.SetCache(cacheKey, timeZones, dp); } } return timeZones; }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The value.</param> /// <param name="dependency">The dependency.</param> /// <param name="absoluteExpiration">The absolute expiration.</param> /// <param name="slidingExpiration">The sliding expiration.</param> /// <param name="priority">The priority.</param> /// <param name="onRemoveCallback">The on remove callback.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { Cache.Insert(cacheKey, itemToCache, dependency == null ? null : dependency.SystemCacheDependency, absoluteExpiration, slidingExpiration, priority, onRemoveCallback); }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The object.</param> /// <param name="dependency">The dependency.</param> /// <param name="absoluteExpiration">The absolute expiration.</param> /// <param name="slidingExpiration">The sliding expiration.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration) { Insert(cacheKey, itemToCache, dependency, absoluteExpiration, slidingExpiration, CacheItemPriority.Default, null); }
/// <summary> /// Inserts the specified cache key. /// </summary> /// <param name="cacheKey">The cache key.</param> /// <param name="itemToCache">The object.</param> /// <param name="dependency">The dependency.</param> public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency) { Insert(cacheKey, itemToCache, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, null); }
public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) { _dictionary[cacheKey] = itemToCache; }
// ReSharper disable SuggestBaseTypeForParameter private static IDictionary<string, string> LoadResource( IDictionary<string, string> resources, string cacheKey, string resourceFile, CustomizedLocale checkCustomCulture, int portalId) { //// ReSharper restore SuggestBaseTypeForParameter string f = null; // Are we looking for customised resources switch (checkCustomCulture) { case CustomizedLocale.None: f = resourceFile; break; case CustomizedLocale.Portal: f = resourceFile.Replace(".RESX", ".Portal-" + portalId.ToString(CultureInfo.InvariantCulture) + ".resx"); break; case CustomizedLocale.Host: f = resourceFile.Replace(".RESX", ".Host.resx"); break; } // If the filename is empty or the file does not exist return the dictionary string filePath = HostingEnvironment.MapPath(f); if (f == null || !File.Exists(filePath)) { return resources; } XPathDocument doc = null; using (var dp = new DNNCacheDependency(filePath)) { bool xmlLoaded; try { // ReSharper disable AssignNullToNotNullAttribute doc = new XPathDocument(filePath); // ReSharper restore AssignNullToNotNullAttribute xmlLoaded = true; } catch { xmlLoaded = false; } if (xmlLoaded) { foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/data")) { if (nav.NodeType != XPathNodeType.Comment) { resources[nav.GetAttribute("name", string.Empty)] = nav.SelectSingleNode("value").Value; } } try { int cacheMinutes = 3 * (int)Host.PerformanceSetting; if (cacheMinutes > 0) { DataCache.SetCache(cacheKey, resources, dp, DateTime.MaxValue, new TimeSpan(0, cacheMinutes, 0)); } } #pragma warning disable 1692 #pragma warning disable EmptyGeneralCatchClause catch { } #pragma warning restore EmptyGeneralCatchClause #pragma warning restore 1692 } } return resources; }
/// <summary> /// Initializes a new instance of the <see cref="DNNCacheDependency"/> classthat monitors an array of paths (to files or directories), /// an array of cache keys, or both for changes. It also makes itself dependent upon a separate instance of the <see cref="DNNCacheDependency"/> class. /// </summary> /// <param name="filenames">The filenames.</param> /// <param name="cachekeys">The cachekeys.</param> /// <param name="dependency">The dependency.</param> public DNNCacheDependency(string[] filenames, string[] cachekeys, DNNCacheDependency dependency) { _fileNames = filenames; _cacheKeys = cachekeys; _cacheDependency = dependency; }
private static void SetPageCache(string key, object value, DNNCacheDependency dependency, FriendlyUrlSettings settings, CacheItemRemovedCallback callback) { DateTime absoluteExpiration = DateTime.Now.Add(settings.CacheTime); DataCache.SetCache(key, value, dependency, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, callback); }
//Method that does the actual disposal of resources protected virtual void Dispose(bool disposing) { if ((disposing)) { if (_cacheDependency != null) { _cacheDependency.Dispose(disposing); } if (_systemCacheDependency != null) { _systemCacheDependency.Dispose(); } _fileNames = null; _cacheKeys = null; _cacheDependency = null; _systemCacheDependency = null; } }
/// <summary> /// Initializes a new instance of the <see cref="DNNCacheDependency"/> class that monitors an array of paths (to files or directories), /// an array of cache keys, or both for changes. /// It also makes itself dependent upon another instance of the <see cref="DNNCacheDependency"/> class and a time when the change monitoring begins. /// </summary> /// <param name="filenames">The filenames.</param> /// <param name="cachekeys">The cachekeys.</param> /// <param name="dependency">The dependency.</param> /// <param name="start">The start.</param> public DNNCacheDependency(string[] filenames, string[] cachekeys, DNNCacheDependency dependency, DateTime start) { _utcStart = start.ToUniversalTime(); _fileNames = filenames; _cacheKeys = cachekeys; _cacheDependency = dependency; }
/// <summary> /// Initializes a new instance of the <see cref="DNNCacheDependency"/> classthat monitors an array of paths (to files or directories), /// an array of cache keys, or both for changes. It also makes itself dependent upon a separate instance of the <see cref="DNNCacheDependency"/> class. /// </summary> /// <param name="filenames">The filenames.</param> /// <param name="cachekeys">The cachekeys.</param> /// <param name="dependency">The dependency.</param> public DNNCacheDependency(string[] filenames, string[] cachekeys, DNNCacheDependency dependency) { _fileNames = filenames; _cacheKeys = cachekeys; _cacheDependency = dependency; }