Beispiel #1
0
 /// <summary>
 /// Retrieves the remote RSS feed and inserts it into the cache
 /// when it has expired.
 /// </summary>
 private static void RefreshCache(string key, object item, CacheItemRemovedReason reason)
 {
     if (reason != CacheItemRemovedReason.Removed)
     {
         string    feedUrl = key.Replace("RssReader_", String.Empty);
         RssReader reader  = new RssReader(feedUrl);
         reader.Execute();
         reader._UpdateFrequenzy = ((RssReader)item).UpdateFrequenzy;
         HttpRuntime.Cache.Add("RssReader_" + feedUrl, reader, null, DateTime.Now.Add(reader.UpdateFrequenzy), Cache.NoSlidingExpiration, CacheItemPriority.Normal, RefreshCache);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Creates an RssReader instance from the specified URL
        /// and inserts it into the cache. When it expires from the cache,
        /// it automatically retrieves the remote RSS feed and inserts it
        /// to the cache again.
        /// </summary>
        /// <param name="feedUrl">The URI of the RSS feed.</param>
        /// <param name="updateFrequenzy">The time before it should update it self.</param>
        /// <returns>An instance of the RssReader class.</returns>
        public static RssReader CreateAndCache(string feedUrl, TimeSpan updateFrequenzy)
        {
            if (HttpRuntime.Cache["RssReader_" + feedUrl] == null)
            {
                RssReader reader = new RssReader(feedUrl);
                reader.Execute();
                reader._UpdateFrequenzy = updateFrequenzy;
                HttpRuntime.Cache.Add("RssReader_" + feedUrl, reader, null, DateTime.Now.Add(updateFrequenzy), Cache.NoSlidingExpiration, CacheItemPriority.Normal, RefreshCache);
            }

            return((RssReader)HttpContext.Current.Cache["RssReader_" + feedUrl]);
        }
Beispiel #3
0
 /// <summary>
 /// Retrieves the remote RSS feed and inserts it into the cache
 /// when it has expired.
 /// </summary>
 private static void RefreshCache(string key, object item, CacheItemRemovedReason reason)
 {
     if (reason != CacheItemRemovedReason.Removed)
     {
         string feedUrl = key.Replace("RssReader_", String.Empty);
         RssReader reader = new RssReader(feedUrl);
         reader.Execute();
         reader._UpdateFrequenzy = ((RssReader)item).UpdateFrequenzy;
         HttpRuntime.Cache.Add("RssReader_" + feedUrl, reader, null, DateTime.Now.Add(reader.UpdateFrequenzy), Cache.NoSlidingExpiration, CacheItemPriority.Normal, RefreshCache);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Creates an RssReader instance from the specified URL
        /// and inserts it into the cache. When it expires from the cache, 
        /// it automatically retrieves the remote RSS feed and inserts it 
        /// to the cache again.
        /// </summary>
        /// <param name="feedUrl">The URI of the RSS feed.</param>
        /// <param name="updateFrequenzy">The time before it should update it self.</param>
        /// <returns>An instance of the RssReader class.</returns>
        public static RssReader CreateAndCache(string feedUrl, TimeSpan updateFrequenzy)
        {
            if (HttpRuntime.Cache["RssReader_" + feedUrl] == null)
            {
                RssReader reader = new RssReader(feedUrl);
                reader.Execute();
                reader._UpdateFrequenzy = updateFrequenzy;
                HttpRuntime.Cache.Add("RssReader_" + feedUrl, reader, null, DateTime.Now.Add(updateFrequenzy), Cache.NoSlidingExpiration, CacheItemPriority.Normal, RefreshCache);
            }

            return (RssReader)HttpContext.Current.Cache["RssReader_" + feedUrl];
        }