Add cache in spark iterations