5 ms·
What I'm doing in my homegrown framework to avoid/reduce memcache dogpiling is this (pseudocode): n = 1000; key = "myMemCacheEntry"; if (random(0,n) ==
by andr 19y ago
What I'm doing in my homegrown framework to avoid/reduce memcache dogpiling is this (pseudocode):
n = 1000;
key = "myMemCacheEntry";
if (random(0,n) == 1 || (value = memcache_get(key)) == false) {
value = compute_value();
memcache_put(key,value);
}
return value;
Adjust n 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.