Added defined checks around memcache