Changed logic for memcached.