Magnetic cooling by the application of external pressure in rare-earth compounds