When I set out to do the multi-index cache, it occurred to me that instead of using the secondary indexes as mappings to the primary index, I could just store another reference to the same object.
I don’t know why I didn’t choose to do it that way, but now that I’ve been thinking about it for a while, I don’t see why not. It would eliminate a second lookup, and I can’t think of any adverse affects.
So, if there are 3 indexes, then instead of storing one object reference and 3 keys, we store three object references and three keys.
The next time I’m in there, I’ll change it and see if I’m forgetting anything. The API doesn’t change at all, just the innards.