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