Refactor shared code into abstract base class AbstractPathKeyCache