class ZuoraConnect::AppInstanceBase

def cache_app_instance(force_cache: false)

def cache_app_instance(force_cache: false)
  if defined?(Redis.current)
    #Task data must be present and the last refresh cannot be old. We dont want to overwite new cache data with old
    if self.task_data.present? &&  ((self.last_refresh.to_i > INSTANCE_REFRESH_WINDOW.ago.to_i ) || force_cache)
      ZuoraConnect.logger.debug("Caching AppInstance", self.default_ougai_items)
      Redis.current.setex("AppInstance:#{self.id}", INSTANCE_REDIS_CACHE_PERIOD.to_i, self.encrypt_data(data: self.save_data))
    end
  end
end