I've moved the @cache ||= {} line so that is no longer the case, but I am thinking I can possibly rewrite this using nil values rather than {} values.