[cjh] Add ability to cache history queries.

[mms] Abstract history query caching to use Horde_HashTable.