def METHOD_NAME(self, name, obj):
    """Return an item from the cache if the obj matches the previous invalidation object. Clears the cache and returns None if not."""
    if not self.invalidation_object:
        self.invalidation_object = obj
    if self.invalidation_object == obj:
        log.debug('Trying guessit cache for item {name}', {'name': name})
        return self.get(name)
    log.debug('GuessIt cache was cleared due to invalidation object change: previous={previous} new={new}',
              {'previous': self.invalidation_object, 'new': obj})
    self.invalidation_object = obj
    self.clear()
    return None