Move cache class to separate file