def clear_cached_posts(sender, instance, **kwargs):
    """when a model is saved clear the cache on the query
    and the cache on it's rendered page

    - archive_dates
    - posts_published
    - posts_idea
    - posts_draft
    - posts_hidden
    - tags_and_counts
    - view post
    - archive month
    - all tags for post
    """
    try:
        saved_instance = sender.objects.get(pk=instance.pk)
    except sender.DoesNotExist:
        saved_instance = None
    #
    # TODO: only kill the cache if items have changed .
    # e.g if the description, title, slug has changed nuke the
    #       index
    #       archive
    #
    kill_list = []
    # dates
    if getattr(saved_instance, 'created', None) != instance.created:
        kill_list.append(get_key('archive_dates'))
        kill_list.append(
            get_key('month_%s_%s' % (
                instance.created.year,
                instance.created.month)))
    try:
        kill_list.append(
            get_key('month_%s_%s' % (
                saved_instance.created.year,
                saved_instance.created.month)))
    except AttributeError:
        pass

    # Just nuke all of the below for now
    kill_list.append(get_key('posts_published'))
    kill_list.append(get_key('posts_idea'))
    kill_list.append(get_key('posts_draft'))
    kill_list.append(get_key('posts_hidden'))
    kill_list.append(get_key('tags_and_counts'))
    kill_list.append(get_key('index_'))

    # always nuke the post
    kill_list.append(get_key('post_%s' % instance.slug))

    # nuke tags
    try:
        for tag in instance.tags.all():
            kill_list.append(get_key('tag_%s' % tag))
    except __HOLE__:
        pass
    cache.delete_many(kill_list)
dataset/ETHPy150Open jamiecurle/django-omblog/omblog/listeners.py/clear_cached_posts