LRUCache optimisation

This improves LRUCache performance pretty substantially (particularly for the multithreaded case) while keeping the same basic algorithm as it had before. I'm afraid the bulk of the work is in a single commit, because the rather wandering path I took to get to this point didn't make sense as individual commits. I have however added a lot of documentation to the private members which hopefully does a pretty decent job of explaining what's going on - so it probably makes more sense just to read the final result rather than look at the diffs.
They date from a time when the threading was a bit more complex, and there was a code path that unlocked the mutex before getting in here. They're still valid assertions though, if a little obvious right now.

I don't mind removing them if you feel strongly about it, but if we're considering future changes (including pooling mutexes) then I'd vote to keep them. As someone who spent the best part of last week tangling with this code, I can assure you that assertions are a very useful thing to have when dealing with it.