Move Patch entity out of database and store only in cache

Rather than storing every Patch entity for all time we can store the
active Patch entities in a cache, and only keep the most recent ones
we need to load to present to the user.  This dramatically shrinks
the database by removing redundant information, information that
we can quickly pull from Git when necessary, but that we can pull
out of Ehcache even faster.

Removing the patches table kills one of the largest sources of
bloat in our database, e.g. on one server:

   changes | patch_sets | patches | comments
  ---------+------------+---------+----------
    13,431 |     22,060 | 212,604 |   15,645

This also reduces the amount of information which might need to be
moved into a Git based datastore, as Gerrit can just as easily get
the data from the surrounding project repository on demand.

We no longer prime the cache when the commit is pushed and first
stored into the database, but instead wait for the first rendering
from a web client.  This allows us to avoid unnecessary production
of diff entries, such as when we replace a patch set on a change
during a direct git push.

Change-Id: If4cf2f8779ad4c6f31433083849ae78806d3831c
Signed-off-by: Shawn O. Pearce <sop@google.com>
34 files changed