@register.assignment_tag
def package_count():
    cached = cache.get("crate:stats:package_count")

    if cached:
        return cached

    count = Package.objects.all().count()
    cache.set("crate:stats:package_count", count, 60 * 60)
    return count
dataset/ETHPy150Open crateio/crate.web/crate/web/packages/templatetags/package_tags.py/package_count/original