ASP.Net Context.Cache

Latest post 09-26-2008 5:57 PM by Pat. 0 replies.
  • 09-26-2008 5:57 PM

    • Pat
    • Top 10 Contributor
      Male
    • Joined on 04-27-2008
    • Tempe, AZ
    • Posts 45

    ASP.Net Context.Cache

    Here's some code to set a cache variable in the global.asax.

    http://www.developer.com/net/net/article.php/1477771

         static Cache _cache = null;
       
        protected void Application_Start(object sender, EventArgs e)
        {
            _cache = Context.Cache;

            _cache.Insert("UserCount", BusinessObjects.ActiveUserCounter.GetUserCount(), null,
          DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal,
          new CacheItemRemovedCallback(RefreshUserCount));
        }

        static void RefreshUserCount(String key, Object item,
          CacheItemRemovedReason reason)
        {
            _cache.Insert("UserCount", BusinessObjects.ActiveUserCounter.GetUserCount(), null,
           DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal,
           new CacheItemRemovedCallback(RefreshUserCount));
        } 

    Patrick McNamara, BS-IS/CS, MBA, MAED
    ASP.NET Web Application Developer
    Asteryx, LLC.
    http://asteryx.com
    pat@asteryx.com

    Filed under: , , ,
Page 1 of 1 (1 items) | RSS
Forums to discuss Microsoft ASP.Net Development and SQL
Powered by Community Server (Non-Commercial Edition), by Telligent Systems