DistCache.Get always returns Null

Aug 10, 2009 at 3:53 PM

Hi people,

We are getting a strange behavior on our servers.

In production, the application Set something in MemCacheD and all ok, we can Get these value.

But the same application on our servers Set in the right way (in MemCacheD Manager a can see many itens stored on the MemCacheD instance) but can't Get anything.

All Gets returns null!

The MemCacheD instance is running well and no errors are found (no exceptions on the application, no eventlogs, no logfiles, nothing).

And now? Anyone know anything about it?



Aug 10, 2009 at 4:11 PM

This behaviour will happen when the key used in the Set is different from the Get.
Is one application doing a set and other doing a get. Check

cacheProvider - keySuffix="_Plant_" attribute and compare the values. They should be the same.


Aug 10, 2009 at 4:39 PM

Hi Fahad,

Thanks by the fast response, but I think that I don't understood... Sorry.

Well, here is one of my codes that Set and Get into MemCacheD. Is there anything wrong with it?

var l = login.ToString().ToLower();
var user = DistCache.Get<UserProfile>("User-" + l);

if (user == null)
    System.Diagnostics.EventLog.WriteEntry("MySite", "Profile not in Cache. Loading from DB.");

    using (var provider = new BusinessProvider())
        user = provider.GetUserProfileByLogin(l);

    DistCache.Add("User-" + l, user, TimeSpan.FromDays(20));

return user;

Thanks one more time.


Aug 11, 2009 at 9:21 PM

I don't see a problem with your code. As it is working fine in the production, problem has to be in configuration of the local enviorment.
It's a bit hard to say what is wrong. More info would be useful.

- Fahad