extract cache into its own class