Vaccinated people's risk of dementia was reduced by 20% over a seven year period, researchers have found.