refactor cache persistence