What I'm doing in my homegrown framework to avoid/reduce memcache dogpiling is this (pseudocode):<p><pre><code> n = 1000;
key = "myMemCacheEntry";
if (random(0,n) == 1 || (value = memcache_get(key)) == false) {
value = compute_value();
memcache_put(key,value);
}
return value;
</code></pre>
Adjust <i>n</i> according to your current peak traffic. When traffic is low, the algorithm won't always catch on, but the dogpiling won't be as severe.