开发者

System.Web.Caching.Cache returning null for a key in the cache

开发者 https://www.devze.com 2023-01-04 01:28 出处:网络
I have some code(client side) that is trying to cache responses from a web service.I save the responses in a System.Web.Caching.Cache object gotten from System.Web.HttpRuntime.

I have some code(client side) that is trying to cache responses from a web service. I save the responses in a System.Web.Caching.Cache object gotten from System.Web.HttpRuntime.

I make a call once, then i make it again and have a console output saying it loaded from cache. But I am never getting the console output. I ran it in a debugger and put a break point at the Get and the Cache as the entry and the key inside the cache is the same as the key I'm passing into the get but it still returns null?????

basically the code looks like this.


public object MakeRequest(string uri)
{
(break point)object开发者_开发问答 retList = Querier.Cache.Get(uri);

            if (retList != null)
            {
                Console.WriteLine("Loaded from Cache");

            }
            retList = Querier.MakeRequest(uri);
            Querier.Chache[uri] = retList;
            return retList;
}

Querier is an object that makes my http request and deserializes the object then returns it.

Anyone have an idea about why the cache is returning null and not the object stored in it? this one has me at a loss because the debugger shows that both the internal key and the one I'm passing in are the same string(although not formed at the same place) Thanks in advance


So it turns out i didn't look quite close enough at the two strings and one was slightly diffrent fromt he other, they both went to the same webpage but weren't equal by string comparor method.

0

精彩评论

暂无评论...
验证码 换一张
取 消