How To Distinguish Between a Crashed Server and Non-Existent
Memcached Key Value?
avierengel at gatrixx.com
Sun Jun 4 09:35:56 UTC 2006
Garrett Rooney wrote:
> On 6/1/06, EKC <webmaster at generalsynthesis.com> wrote:
>> How can I differentiate between a missing KEY->server mapping (when
>> Cache::Memcached::get() returns undef) and a crashed server (which
>> also results in 'undef')?
> If you are using memcached correctly you should not differentiate
> between the two cases. You should always be able to handle the case
> where memcached does not have a particular value, the exact reason it
> doesn't have it is meaningless, that's core to the way it works. For
> example, you could also get an undef response simply because the cache
> filled up and dropped that value out of it. You still need to handle
> that case as well.
that's right, but it could lead to a nice DoS-Attack especially if (for
example) a web-request leads to a specific key which cannot be filled
from the original source, because the original source produces 'undef'
One solution could be that you never let this happen and always generate
a "reasonable" value for this key, or you could hack Cache::Memcached to
add a undef-state using the flags-field.
More information about the memcached