How to avoid cacheLoaders persisting after plugin install?

In newer versions of our addon we’re making use of the newer atlassian cache api, fetching our cache with a supplied loader:

cache = cacheManager.getCache("myCache", cacheLoader, settings);

which works nicely. The loader executes the first time and on misses to load a value.

In older versions of our add-on the equivalent code looked like this:

cache = cacheManager.getCache("myCache");

If you’re uninstalling the newer version and installing an older version, the line above will still trigger the loader to run, even though it’s no longer present in the add-on. This is causing some issues for us. How can I make sure to remove the loader? Flushing/Clearing the cache doesn’t seem to work.