Skip to content

Commit

Permalink
Merge pull request liangliangyy#576 from xiuyuanjun/dev_gravatar_2022…
Browse files Browse the repository at this point in the history
…04202129

优化代码--添加加载侧边栏和gravatar头像时初始化缓存的日志输出
  • Loading branch information
liangliangyy authored Apr 21, 2022
2 parents 14200e9 + fe9e2c1 commit db7e882
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def load_sidebar(user, linktype):
'extra_sidebars': extra_sidebars
}
cache.set("sidebar" + linktype, value, 60 * 60 * 60 * 3)
logger.info('set sidebar cache.key:{key}'.format(key="sidebar" + linktype))
value['user'] = user
return value

Expand Down Expand Up @@ -302,6 +303,7 @@ def gravatar_url(email, size=40):
url = "https://www.gravatar.com/avatar/%s?%s" % (hashlib.md5(
email.lower()).hexdigest(), urllib.parse.urlencode({'d': default, 's': str(size)}))
cache.set(cachekey, url, 60 * 60 * 10)
logger.info('set gravatar cache.key:{key}'.format(key=cachekey))
return url


Expand Down

0 comments on commit db7e882

Please sign in to comment.