def query_user_by_id(user_id=0, use_cache=True):
"""
????????
:param user_id: ???ID
:param use_cache: ??????
"""
key = CACHE_KEY+str(user_id)
if use_cache:
account = cache.get(key)
if account:
return account
try:
account = UserAccount.objects.get(id=user_id)
cache.set(key, account, CACHE_TIME)
return account
except UserAccount.DoesNotExist:
return None
评论列表
文章目录