def query_published_article_count(user_id, use_cache=True):
"""
??????????????
:param user_id: ??ID
:param use_cache: ??????
"""
cache_key = CACHE_ARTICLE_COUNT + str(user_id)
if use_cache:
count = cache.get(cache_key)
if count:
return count
count = BlogArticle.objects.filter(user_id=user_id, status=1).aggregate(Count("id"))
count = count["id__count"]
if count:
cache.set(cache_key, count, CACHE_TIME)
return count
评论列表
文章目录