HttpContext.Current.Cache issue. HELP!!!

Discussion in 'Site Programming, Development and Design' started by Zilog80, Mar 17, 2012.

  1. Hi guys!

    I have this code in my Global.asax.cs file:

    Code:
    private void RegisterCacheEntry()
    {
        // Prevent duplicate key addition
        if (null != HttpContext.Current.Cache[testCacheItemKey]) return;
    
        HttpContext.Current.Cache.Add(testCacheItemKey, "Test", null, DateTime.Now.AddSeconds(60),
                    Cache.NoSlidingExpiration,CacheItemPriority.High,
                    new CacheItemRemovedCallback(CacheItemRemovedCallback));
    
        DebugToLogFile("Waiting for 'CallBack' Firing...");
    }
    
    
    public void CacheItemRemovedCallback(
                string key,
                object value,
                CacheItemRemovedReason reason
                )
    {
        DoStuff();
    }
    
    i used this MSDN article like a example.

    I also tried with this code:
    Code:
    HttpContext.Current.Cache.Add(testCacheItemKey, "Test", null, DateTime.MaxValue,
    	    TimeSpan.FromMinutes(1), CacheItemPriority.NotRemovable,
                new CacheItemRemovedCallback(CacheItemRemovedCallback));
    
    The 'problem' is that the CacheItemRemovedCallback never fires :(

    I started my Winhost application, and see on my Winhostdomain\myLogFile.txt the entry 'Waiting for 'CallBack' Firing...' but i wait 1 minute, 2 minutes, 10 minutes, 20 minutes and nothing happens (in DoStuff() i have another DebugToLogFile call)

    I have been lookingin IIS Manager somethig about resource's cache but i didnt see nothing relevant.

    I need to find an urgent solution to this problem.

    Any ideas?

    Best regards.
     
    Last edited by a moderator: Oct 14, 2015
  2. On local enviroment my code works properly (using the Visual Studio asp web server)
    But when o deploy application to my Winhost site the CacheItemRemovedCallback never fires

    I need to find a solution asap!.

    Any ideas?

    Thanks in advance.
     
    Last edited by a moderator: Oct 14, 2015

Share This Page