Cache MessageIndex key values
Currently this does the same query lots of times
(tens of times in one request). Applying this patch
decreased the number of DatabaseMessageIndex::get()
queries in one request from 55 to 3.
Limit is 30, which is just an arbitrary number.
Bug: T136219
Change-Id: If9cb5ebc443927b2be4fc549cfcf3c6be489b576