Set the cache before r2.lib.db.thing takes the wrong reference

This is another attempt to stop the db export from using all memory

[#62525492]
Merge branch 'master' into staging