very simplistic url cache flushing

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from django.conf import settings
from django.core.cache import cache
from django.utils.encoding import iri_to_uri

def delete_url_cache(url):
    """ simple method to delete the cache for a particular URL """
    key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix,
                                                               iri_to_uri(url))
    cache.delete(cache_key)

Comments

grep (on August 4, 2008):

Duplicate of http://www.djangosnippets.org/snippets/936/

#

jpt (on August 5, 2008):

oops, it certainly is.. my mistake not seeing if anything had been submitted since last time i checked

#

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.