Drama fever multidb

This is an odd direction for a pull request, but I wanted to get your feedback and testing on this code. I rebased your branch against master and then fixed the byid tests by slipping `obj._state.db` into all the other cache keys, which seems like the right to do. What do you think?

(If you update your master branch the compare view will look more manageable.)