Fixed error that would crash host application if memcached server went away.

The code is not super pretty, but the idea is pretty obvious.