Japan has raised interest rates to the highest level in 31 years as the economy faces persistent inflation, partly driven by conflict in the Middle East.