Refactor cache singleton to factory / bean.