System.Runtime.Cache expires instantly











up vote
6
down vote

favorite
1












I have a webpage which caches some querystring values for 30 seconds so that it does not receive duplicate values. I am using the following class:



public class MyCache   {

private static ObjectCache cache = MemoryCache.Default;

public MyCache() { }


public void Insert(string key, string value)
{

CacheItemPolicy policy = new CacheItemPolicy();
policy.Priority = CacheItemPriority.Default;
policy.SlidingExpiration = new TimeSpan(0, 0, 30);
policy.RemovedCallback = new CacheEntryRemovedCallback(this.Cacheremovedcallback);

cache.Set(key, value, policy);
}

public bool Exists(string key)
{
return cache.Contains(key);
}

public void Remove(string key)
{
cache.Remove(key);
}

private void Cacheremovedcallback(CacheEntryRemovedArguments arguments)
{
FileLog.LogToFile("Cache item removed. Reason: " + arguments.RemovedReason.ToString() + "; Item: [" + arguments.CacheItem.Key + ", " + arguments.CacheItem.Value.ToString() + "]");
}
}


This has worked fine for a couple of weeks then suddenly the cache doesn't keep the values anymore. The CacheRemoved callback fires instantly after an item is inserted into cache and i get the removed reason: CacheSpecificEviction
This is running on a Windows Server 2008 SP1, IIS7.5 with .NET 4.0. No changes were applied to the OS or IIS during this time.



Is there a way to solve this and if not, is there a better cache solution to use in a web page ?



Thank you in advance.










share|improve this question






















  • Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
    – Daniel Kelley
    Feb 15 '13 at 10:27






  • 1




    See this post for explanation. stackoverflow.com/questions/5380875/…
    – Rob Epstein
    Feb 15 '13 at 10:42










  • Will it be possible for you to post a sample solution with the issue?
    – Dipen Shah
    Nov 19 at 18:17















up vote
6
down vote

favorite
1












I have a webpage which caches some querystring values for 30 seconds so that it does not receive duplicate values. I am using the following class:



public class MyCache   {

private static ObjectCache cache = MemoryCache.Default;

public MyCache() { }


public void Insert(string key, string value)
{

CacheItemPolicy policy = new CacheItemPolicy();
policy.Priority = CacheItemPriority.Default;
policy.SlidingExpiration = new TimeSpan(0, 0, 30);
policy.RemovedCallback = new CacheEntryRemovedCallback(this.Cacheremovedcallback);

cache.Set(key, value, policy);
}

public bool Exists(string key)
{
return cache.Contains(key);
}

public void Remove(string key)
{
cache.Remove(key);
}

private void Cacheremovedcallback(CacheEntryRemovedArguments arguments)
{
FileLog.LogToFile("Cache item removed. Reason: " + arguments.RemovedReason.ToString() + "; Item: [" + arguments.CacheItem.Key + ", " + arguments.CacheItem.Value.ToString() + "]");
}
}


This has worked fine for a couple of weeks then suddenly the cache doesn't keep the values anymore. The CacheRemoved callback fires instantly after an item is inserted into cache and i get the removed reason: CacheSpecificEviction
This is running on a Windows Server 2008 SP1, IIS7.5 with .NET 4.0. No changes were applied to the OS or IIS during this time.



Is there a way to solve this and if not, is there a better cache solution to use in a web page ?



Thank you in advance.










share|improve this question






















  • Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
    – Daniel Kelley
    Feb 15 '13 at 10:27






  • 1




    See this post for explanation. stackoverflow.com/questions/5380875/…
    – Rob Epstein
    Feb 15 '13 at 10:42










  • Will it be possible for you to post a sample solution with the issue?
    – Dipen Shah
    Nov 19 at 18:17













up vote
6
down vote

favorite
1









up vote
6
down vote

favorite
1






1





I have a webpage which caches some querystring values for 30 seconds so that it does not receive duplicate values. I am using the following class:



public class MyCache   {

private static ObjectCache cache = MemoryCache.Default;

public MyCache() { }


public void Insert(string key, string value)
{

CacheItemPolicy policy = new CacheItemPolicy();
policy.Priority = CacheItemPriority.Default;
policy.SlidingExpiration = new TimeSpan(0, 0, 30);
policy.RemovedCallback = new CacheEntryRemovedCallback(this.Cacheremovedcallback);

cache.Set(key, value, policy);
}

public bool Exists(string key)
{
return cache.Contains(key);
}

public void Remove(string key)
{
cache.Remove(key);
}

private void Cacheremovedcallback(CacheEntryRemovedArguments arguments)
{
FileLog.LogToFile("Cache item removed. Reason: " + arguments.RemovedReason.ToString() + "; Item: [" + arguments.CacheItem.Key + ", " + arguments.CacheItem.Value.ToString() + "]");
}
}


This has worked fine for a couple of weeks then suddenly the cache doesn't keep the values anymore. The CacheRemoved callback fires instantly after an item is inserted into cache and i get the removed reason: CacheSpecificEviction
This is running on a Windows Server 2008 SP1, IIS7.5 with .NET 4.0. No changes were applied to the OS or IIS during this time.



Is there a way to solve this and if not, is there a better cache solution to use in a web page ?



Thank you in advance.










share|improve this question













I have a webpage which caches some querystring values for 30 seconds so that it does not receive duplicate values. I am using the following class:



public class MyCache   {

private static ObjectCache cache = MemoryCache.Default;

public MyCache() { }


public void Insert(string key, string value)
{

CacheItemPolicy policy = new CacheItemPolicy();
policy.Priority = CacheItemPriority.Default;
policy.SlidingExpiration = new TimeSpan(0, 0, 30);
policy.RemovedCallback = new CacheEntryRemovedCallback(this.Cacheremovedcallback);

cache.Set(key, value, policy);
}

public bool Exists(string key)
{
return cache.Contains(key);
}

public void Remove(string key)
{
cache.Remove(key);
}

private void Cacheremovedcallback(CacheEntryRemovedArguments arguments)
{
FileLog.LogToFile("Cache item removed. Reason: " + arguments.RemovedReason.ToString() + "; Item: [" + arguments.CacheItem.Key + ", " + arguments.CacheItem.Value.ToString() + "]");
}
}


This has worked fine for a couple of weeks then suddenly the cache doesn't keep the values anymore. The CacheRemoved callback fires instantly after an item is inserted into cache and i get the removed reason: CacheSpecificEviction
This is running on a Windows Server 2008 SP1, IIS7.5 with .NET 4.0. No changes were applied to the OS or IIS during this time.



Is there a way to solve this and if not, is there a better cache solution to use in a web page ?



Thank you in advance.







c# .net caching






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 15 '13 at 10:24









user2075034

3112




3112












  • Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
    – Daniel Kelley
    Feb 15 '13 at 10:27






  • 1




    See this post for explanation. stackoverflow.com/questions/5380875/…
    – Rob Epstein
    Feb 15 '13 at 10:42










  • Will it be possible for you to post a sample solution with the issue?
    – Dipen Shah
    Nov 19 at 18:17


















  • Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
    – Daniel Kelley
    Feb 15 '13 at 10:27






  • 1




    See this post for explanation. stackoverflow.com/questions/5380875/…
    – Rob Epstein
    Feb 15 '13 at 10:42










  • Will it be possible for you to post a sample solution with the issue?
    – Dipen Shah
    Nov 19 at 18:17
















Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
– Daniel Kelley
Feb 15 '13 at 10:27




Is it possible your cache has reached it's limit in size? Is it removing old items as new ones are added due to space constraints?
– Daniel Kelley
Feb 15 '13 at 10:27




1




1




See this post for explanation. stackoverflow.com/questions/5380875/…
– Rob Epstein
Feb 15 '13 at 10:42




See this post for explanation. stackoverflow.com/questions/5380875/…
– Rob Epstein
Feb 15 '13 at 10:42












Will it be possible for you to post a sample solution with the issue?
– Dipen Shah
Nov 19 at 18:17




Will it be possible for you to post a sample solution with the issue?
– Dipen Shah
Nov 19 at 18:17












2 Answers
2






active

oldest

votes

















up vote
1
down vote



+150










Looking at the source code of MemoryCacheStore (that should be the default store used by MemoryCache.Default) it seems that the remove callback with argument CacheSpecificEviction is only called when the cache is disposed:



https://referencesource.microsoft.com/#System.Runtime.Caching/System/Caching/MemoryCacheStore.cs,230



Look around and make sure your cache object is not being disposed accidentally.






share|improve this answer




























    up vote
    -1
    down vote













    Try this one:



    policy.AbsoluteExpiration = DateTime.Now.AddSeconds(30);


    Thats how I use Cache:



    public static class CacheHelper
    {
    private static ObjectCache _cache;
    private const Double ChacheExpirationInMinutes = 10;

    /// <summary>
    /// Insert value into the cache using
    /// appropriate name/value pairs
    /// </summary>
    /// <typeparam name="T">Type of cached item</typeparam>
    /// <param name="entity">item cached</param>
    /// <param name="key">Name of item</param>
    public static void Add<T>(T entity, string key) where T : class
    {
    if (_cache == null)
    {
    _cache = MemoryCache.Default;
    }
    if (_cache.Contains(key))
    _cache.Remove(key);
    CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
    cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddMinutes(ChacheExpirationInMinutes);
    _cache.Set(key, entity, cacheItemPolicy);
    }

    /// <summary>
    /// Remove item from cache
    /// </summary>
    /// <param name="key">Name of cached item</param>
    public static void Clear(string key)
    {
    if (_cache == null)
    {
    _cache = MemoryCache.Default;
    return;
    }
    _cache.Remove(key);
    }

    /// <summary>
    /// Retrieve cached item
    /// </summary>
    /// <typeparam name="T">Type of cached item</typeparam>
    /// <param name="key">Name of cached item</param>
    /// <returns>Cached item as type</returns>
    public static T Get<T>(string key) where T : class
    {
    if (_cache == null)
    {
    _cache = MemoryCache.Default;
    }
    try
    {
    return (T)_cache.Get(key);
    }
    catch
    {
    return null;
    }
    }
    }





    share|improve this answer





















    • Not sure how this solves the issue. As they said, it works for a while then stops working.
      – Daniel Kelley
      Feb 15 '13 at 10:46










    • Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
      – Maris
      Feb 15 '13 at 10:48










    • I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
      – Maris
      Feb 15 '13 at 10:51












    • Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
      – user2075034
      Feb 15 '13 at 12:23











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14892621%2fsystem-runtime-cache-expires-instantly%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    +150










    Looking at the source code of MemoryCacheStore (that should be the default store used by MemoryCache.Default) it seems that the remove callback with argument CacheSpecificEviction is only called when the cache is disposed:



    https://referencesource.microsoft.com/#System.Runtime.Caching/System/Caching/MemoryCacheStore.cs,230



    Look around and make sure your cache object is not being disposed accidentally.






    share|improve this answer

























      up vote
      1
      down vote



      +150










      Looking at the source code of MemoryCacheStore (that should be the default store used by MemoryCache.Default) it seems that the remove callback with argument CacheSpecificEviction is only called when the cache is disposed:



      https://referencesource.microsoft.com/#System.Runtime.Caching/System/Caching/MemoryCacheStore.cs,230



      Look around and make sure your cache object is not being disposed accidentally.






      share|improve this answer























        up vote
        1
        down vote



        +150







        up vote
        1
        down vote



        +150




        +150




        Looking at the source code of MemoryCacheStore (that should be the default store used by MemoryCache.Default) it seems that the remove callback with argument CacheSpecificEviction is only called when the cache is disposed:



        https://referencesource.microsoft.com/#System.Runtime.Caching/System/Caching/MemoryCacheStore.cs,230



        Look around and make sure your cache object is not being disposed accidentally.






        share|improve this answer












        Looking at the source code of MemoryCacheStore (that should be the default store used by MemoryCache.Default) it seems that the remove callback with argument CacheSpecificEviction is only called when the cache is disposed:



        https://referencesource.microsoft.com/#System.Runtime.Caching/System/Caching/MemoryCacheStore.cs,230



        Look around and make sure your cache object is not being disposed accidentally.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 at 16:38









        Alberto

        11.4k63343




        11.4k63343
























            up vote
            -1
            down vote













            Try this one:



            policy.AbsoluteExpiration = DateTime.Now.AddSeconds(30);


            Thats how I use Cache:



            public static class CacheHelper
            {
            private static ObjectCache _cache;
            private const Double ChacheExpirationInMinutes = 10;

            /// <summary>
            /// Insert value into the cache using
            /// appropriate name/value pairs
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="entity">item cached</param>
            /// <param name="key">Name of item</param>
            public static void Add<T>(T entity, string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            if (_cache.Contains(key))
            _cache.Remove(key);
            CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
            cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddMinutes(ChacheExpirationInMinutes);
            _cache.Set(key, entity, cacheItemPolicy);
            }

            /// <summary>
            /// Remove item from cache
            /// </summary>
            /// <param name="key">Name of cached item</param>
            public static void Clear(string key)
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            return;
            }
            _cache.Remove(key);
            }

            /// <summary>
            /// Retrieve cached item
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="key">Name of cached item</param>
            /// <returns>Cached item as type</returns>
            public static T Get<T>(string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            try
            {
            return (T)_cache.Get(key);
            }
            catch
            {
            return null;
            }
            }
            }





            share|improve this answer





















            • Not sure how this solves the issue. As they said, it works for a while then stops working.
              – Daniel Kelley
              Feb 15 '13 at 10:46










            • Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
              – Maris
              Feb 15 '13 at 10:48










            • I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
              – Maris
              Feb 15 '13 at 10:51












            • Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
              – user2075034
              Feb 15 '13 at 12:23















            up vote
            -1
            down vote













            Try this one:



            policy.AbsoluteExpiration = DateTime.Now.AddSeconds(30);


            Thats how I use Cache:



            public static class CacheHelper
            {
            private static ObjectCache _cache;
            private const Double ChacheExpirationInMinutes = 10;

            /// <summary>
            /// Insert value into the cache using
            /// appropriate name/value pairs
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="entity">item cached</param>
            /// <param name="key">Name of item</param>
            public static void Add<T>(T entity, string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            if (_cache.Contains(key))
            _cache.Remove(key);
            CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
            cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddMinutes(ChacheExpirationInMinutes);
            _cache.Set(key, entity, cacheItemPolicy);
            }

            /// <summary>
            /// Remove item from cache
            /// </summary>
            /// <param name="key">Name of cached item</param>
            public static void Clear(string key)
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            return;
            }
            _cache.Remove(key);
            }

            /// <summary>
            /// Retrieve cached item
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="key">Name of cached item</param>
            /// <returns>Cached item as type</returns>
            public static T Get<T>(string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            try
            {
            return (T)_cache.Get(key);
            }
            catch
            {
            return null;
            }
            }
            }





            share|improve this answer





















            • Not sure how this solves the issue. As they said, it works for a while then stops working.
              – Daniel Kelley
              Feb 15 '13 at 10:46










            • Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
              – Maris
              Feb 15 '13 at 10:48










            • I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
              – Maris
              Feb 15 '13 at 10:51












            • Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
              – user2075034
              Feb 15 '13 at 12:23













            up vote
            -1
            down vote










            up vote
            -1
            down vote









            Try this one:



            policy.AbsoluteExpiration = DateTime.Now.AddSeconds(30);


            Thats how I use Cache:



            public static class CacheHelper
            {
            private static ObjectCache _cache;
            private const Double ChacheExpirationInMinutes = 10;

            /// <summary>
            /// Insert value into the cache using
            /// appropriate name/value pairs
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="entity">item cached</param>
            /// <param name="key">Name of item</param>
            public static void Add<T>(T entity, string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            if (_cache.Contains(key))
            _cache.Remove(key);
            CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
            cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddMinutes(ChacheExpirationInMinutes);
            _cache.Set(key, entity, cacheItemPolicy);
            }

            /// <summary>
            /// Remove item from cache
            /// </summary>
            /// <param name="key">Name of cached item</param>
            public static void Clear(string key)
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            return;
            }
            _cache.Remove(key);
            }

            /// <summary>
            /// Retrieve cached item
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="key">Name of cached item</param>
            /// <returns>Cached item as type</returns>
            public static T Get<T>(string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            try
            {
            return (T)_cache.Get(key);
            }
            catch
            {
            return null;
            }
            }
            }





            share|improve this answer












            Try this one:



            policy.AbsoluteExpiration = DateTime.Now.AddSeconds(30);


            Thats how I use Cache:



            public static class CacheHelper
            {
            private static ObjectCache _cache;
            private const Double ChacheExpirationInMinutes = 10;

            /// <summary>
            /// Insert value into the cache using
            /// appropriate name/value pairs
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="entity">item cached</param>
            /// <param name="key">Name of item</param>
            public static void Add<T>(T entity, string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            if (_cache.Contains(key))
            _cache.Remove(key);
            CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
            cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddMinutes(ChacheExpirationInMinutes);
            _cache.Set(key, entity, cacheItemPolicy);
            }

            /// <summary>
            /// Remove item from cache
            /// </summary>
            /// <param name="key">Name of cached item</param>
            public static void Clear(string key)
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            return;
            }
            _cache.Remove(key);
            }

            /// <summary>
            /// Retrieve cached item
            /// </summary>
            /// <typeparam name="T">Type of cached item</typeparam>
            /// <param name="key">Name of cached item</param>
            /// <returns>Cached item as type</returns>
            public static T Get<T>(string key) where T : class
            {
            if (_cache == null)
            {
            _cache = MemoryCache.Default;
            }
            try
            {
            return (T)_cache.Get(key);
            }
            catch
            {
            return null;
            }
            }
            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 15 '13 at 10:38









            Maris

            3,05122353




            3,05122353












            • Not sure how this solves the issue. As they said, it works for a while then stops working.
              – Daniel Kelley
              Feb 15 '13 at 10:46










            • Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
              – Maris
              Feb 15 '13 at 10:48










            • I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
              – Maris
              Feb 15 '13 at 10:51












            • Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
              – user2075034
              Feb 15 '13 at 12:23


















            • Not sure how this solves the issue. As they said, it works for a while then stops working.
              – Daniel Kelley
              Feb 15 '13 at 10:46










            • Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
              – Maris
              Feb 15 '13 at 10:48










            • I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
              – Maris
              Feb 15 '13 at 10:51












            • Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
              – user2075034
              Feb 15 '13 at 12:23
















            Not sure how this solves the issue. As they said, it works for a while then stops working.
            – Daniel Kelley
            Feb 15 '13 at 10:46




            Not sure how this solves the issue. As they said, it works for a while then stops working.
            – Daniel Kelley
            Feb 15 '13 at 10:46












            Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
            – Maris
            Feb 15 '13 at 10:48




            Actually you are right. Dont think that it will solve the isue. But this class works for me very well even for massive project with a lot of users.
            – Maris
            Feb 15 '13 at 10:48












            I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
            – Maris
            Feb 15 '13 at 10:51






            I have one idea. Maybe you try to save to your cache object with large relation chain. Something Like User--> NxCategories-->NMxProducts-->NM*FxParametrs. What are you holding in your cache?
            – Maris
            Feb 15 '13 at 10:51














            Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
            – user2075034
            Feb 15 '13 at 12:23




            Thank you for your answers. The class provided has the same behaviour as mine. I believe the problem is somewhere in IIS. As i said, i am using it in a web page. An ID received by the webpage via querystring is cached as string. I just query the cache in Page_Load method and if the value is not there, i insert it.
            – user2075034
            Feb 15 '13 at 12:23


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14892621%2fsystem-runtime-cache-expires-instantly%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tonle Sap (See)

            I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

            Guatemaltekische Davis-Cup-Mannschaft