code: def on_post_delete(sender, **kwargs):
      
      if not invalidate:
          return
      if kwargs.get("raw", False):
          return
      if sender is MigrationRecorder.Migration:
          return
      if issubclass(sender, Model):
          obj = kwargs["instance"]
          if isinstance(obj, Model):
              # get_for_model itself is cached
              try:
                  ct = ContentType.objects.get_for_model(sender)
              except RuntimeError:
                  # This happens when ultracache is being used by another product
                  # during a test run.
                  return
  
              # Expire cache keys
              key = "ucache-%s-%s" % (ct.id, obj.pk)
              to_delete = cache.get(key, [])
              if to_delete:
                  try:
                      cache.delete_many(to_delete)
                  except NotImplementedError:
                      for k in to_delete:
                          cache.delete(k)
              cache.delete(key)
  
              # Invalidate paths in reverse caching proxy
              key = "ucache-pth-%s-%s" % (ct.id, obj.pk)
              if purger is not None:
                  for li in cache.get(key, []):
                      purger(li[0], li[1])
              cache.delete(key)
docs: Expire ultracache cache keys affected by this object