Cleanup and performance tweaks for BacklinkCache.

* Batch the queries to get the partitions.
* Improved caching of getNumLinks() with $max.
* Added a TTL to the ProcessCacheLRU use for sanity.
* Some small logic cleanups in partitionResult().
* Also cleaned up some code duplication.

Bug: 43452
Change-Id: I0b9710fe222b3d2cb4dc9ab2eeb0758873a8066c
(cherry picked from commit 4eb056d5491c62c74a4a8ba731bd9704e83a302f)