コード例 #1
0
ファイル: listeners.py プロジェクト: AlexanderAA/django-lfs
def update_category_cache(instance):

    # NOTE: ATM, we clear the whole cache if a category has been changed.
    # Otherwise is lasts to long when the a category has a lot of products
    # (1000s) and the shop admin changes a category.
    clear_cache()
    return
    cache.delete("%s-category-breadcrumbs-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))
    cache.delete("%s-category-products-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))
    cache.delete("%s-category-all-products-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))
    cache.delete("%s-category-categories-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))

    for category in Category.objects.all():
        cache.delete("%s-categories-portlet-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, category.slug))

    cache.delete("%s-category-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))
    cache.delete("%s-category-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))

    cache.delete("%s-category-all-children-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))
    cache.delete("%s-category-children-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))
    cache.delete("%s-category-parents-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))
    cache.delete("%s-category-products-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))
    cache.delete("%s-category-all-products-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.id))

    # Note: As this is called "pre-saved" newly created categories don't have
    # the many-to-many attribute "products", hence we have to take care of it
    # here.
    try:
        for product in instance.products.all():
            update_product_cache(product)
    except ValueError:
        pass
コード例 #2
0
ファイル: listeners.py プロジェクト: potar/lfs
def update_category_cache(instance):

    # NOTE: ATM, we clear the whole cache if a category has been changed.
    # Otherwise is lasts to long when the a category has a lot of products
    # (1000s) and the shop admin changes a category.
    clear_cache()
    return
    cache.delete("category-breadcrumbs-%s" % instance.slug)
    cache.delete("category-products-%s" % instance.slug)
    cache.delete("category-all-products-%s" % instance.slug)
    cache.delete("category-categories-%s" % instance.slug)

    for category in Category.objects.all():
        cache.delete("categories-portlet-%s" % category.slug)

    cache.delete("category-%s" % instance.id)
    cache.delete("category-%s" % instance.slug)

    cache.delete("category-all-children-%s" % instance.id)
    cache.delete("category-children-%s" % instance.id)
    cache.delete("category-parents-%s" % instance.id)
    cache.delete("category-products-%s" % instance.id)
    cache.delete("category-all-products-%s" % instance.id)

    # Note: As this is called "pre-saved" newly created categories don't have
    # the many-to-many attribute "products", hence we have to take care of it
    # here.
    try:
        for product in instance.products.all():
            update_product_cache(product)
    except ValueError:
        pass
コード例 #3
0
ファイル: listeners.py プロジェクト: AlexanderAA/django-lfs
def shop_changed_listener(sender, **kwargs):
    clear_cache()
コード例 #4
0
ファイル: listeners.py プロジェクト: zengchunyun/django-lfs
def shop_changed_listener(sender, **kwargs):
    clear_cache()