Create class for managing cache key.

Moved the cache key generation code into separate class. This will
likely be used for getting cache keys for a page in different contexts
and should be decoupled from the rest of the page cache code.