When a plugin is uninstalled, it should remove all related data from the site (or network, if on multisite). If a plugin adds tables to the database, for example, it should remove those tables from the database.
My question concerns a case like this where the plugin is actually
_doing_it_right() and caching some of the queries that it makes on those database tables, using the
I'm thinking that when the plugin is uninstalled it should probably clear those caches. My reasoning is that sometimes the user might reinstall the plugin after uninstalling (for example if they were just testing it out and want to erase the test data and start fresh). If the caches aren't cleared on uninstall, the plugin might retrieve that ghost data from the caches after it was re-installed, causing very strange behavior.
Of course, this is mostly a concern for those sites that would have persistent caching of some sort. (And it would be exacerbated on those with a pretty big large amount of storage, since the stale data would likely be retained longer.)
For any site with a persistent caching back-end enabled though, having a bunch of stale data sitting in there from an uninstalled plugin is not ideal.
The downside of trying to clear those caches is that there is no way to clear a whole cache group. The plugin would have to loop through all of the IDs of the objects in the database table and clear the cache for each one. So there is resource-usage trade-off between clearing the cache and leaving it.
My question is, has anybody else considered whether plugin caches should be cleared on uninstall, and when the trade-off is worth it? Is this a known best practice?