Commit 6b766e41 authored by 吴升宇's avatar 吴升宇

add redis inrc

parent 326801bb
...@@ -118,10 +118,9 @@ def logins(user_id): ...@@ -118,10 +118,9 @@ def logins(user_id):
def click(cookies_get, id): def click(cookies_get, id):
try: try:
click_key = 'click topic_id:%s, cookies_get: %s' % (str(cookies_get), str(id)) click_key = 'click topic_id:%s, cookies_get: %s' % (str(cookies_get), str(id))
cache_count = click_cache.get(click_key) cache_count = click_cache.inrc(click_key, 1)
click_cache.set(click_key, 1)
click_cache.expire(click_key, settings.CACHE_SECONDS) click_cache.expire(click_key, settings.CACHE_SECONDS)
if cache_count: if cache_count > 1:
return return
except: except:
return return
...@@ -162,10 +161,9 @@ def click(cookies_get, id): ...@@ -162,10 +161,9 @@ def click(cookies_get, id):
def reply(cookies_get, id, content): def reply(cookies_get, id, content):
try: try:
reply_key = 'click topic_id:%s, cookies_get: %s, content:%s' % (str(id), str(cookies_get), str(content)) reply_key = 'click topic_id:%s, cookies_get: %s, content:%s' % (str(id), str(cookies_get), str(content))
cache_count = reply_cache.get(reply_key) cache_count = click_cache.inrc(reply_key, 1)
reply_cache.set(reply_key, 1)
reply_cache.expire(reply_key, settings.CACHE_SECONDS) reply_cache.expire(reply_key, settings.CACHE_SECONDS)
if cache_count: if cache_count > 1:
return return
except: except:
return return
...@@ -296,10 +294,9 @@ def get_comments(): ...@@ -296,10 +294,9 @@ def get_comments():
def follow(cookies_get, id): def follow(cookies_get, id):
try: try:
follow_key = 'click user_id:%s, cookies_get: %s' % (str(id), str(cookies_get)) follow_key = 'click user_id:%s, cookies_get: %s' % (str(id), str(cookies_get))
cache_count = follow_cache.get(follow_key) cache_count = click_cache.inrc(follow_key, 1)
follow_cache.set(follow_key, 1)
follow_cache.expire(follow_key, settings.CACHE_SECONDS) follow_cache.expire(follow_key, settings.CACHE_SECONDS)
if cache_count: if cache_count > 1:
return return
except: except:
return return
...@@ -473,10 +470,9 @@ def reply2(cookies_get, id, content, replied_id): ...@@ -473,10 +470,9 @@ def reply2(cookies_get, id, content, replied_id):
try: try:
reply_key = 'click topic_id:%s, cookies_get: %s, content:%s, replied_id: %s' % \ reply_key = 'click topic_id:%s, cookies_get: %s, content:%s, replied_id: %s' % \
(str(id), str(cookies_get), str(content), str(replied_id)) (str(id), str(cookies_get), str(content), str(replied_id))
cache_count = reply_cache.get(reply_key) cache_count = click_cache.inrc(reply_key, 1)
reply_cache.set(reply_key, 1)
reply_cache.expire(reply_key, settings.CACHE_SECONDS) reply_cache.expire(reply_key, settings.CACHE_SECONDS)
if cache_count: if cache_count > 1:
return return
except: except:
return return
...@@ -504,10 +500,9 @@ def reply2(cookies_get, id, content, replied_id): ...@@ -504,10 +500,9 @@ def reply2(cookies_get, id, content, replied_id):
def pictorial_reply(cookies_get, id, content): def pictorial_reply(cookies_get, id, content):
try: try:
reply_key = 'click topic_id:%s, cookies_get: %s, content:%s' % (str(id), str(cookies_get), str(content)) reply_key = 'click topic_id:%s, cookies_get: %s, content:%s' % (str(id), str(cookies_get), str(content))
cache_count = reply_cache.get(reply_key) cache_count = click_cache.inrc(reply_key, 1)
reply_cache.set(reply_key, 1)
reply_cache.expire(reply_key, settings.CACHE_SECONDS) reply_cache.expire(reply_key, settings.CACHE_SECONDS)
if cache_count: if cache_count > 1:
return return
except: except:
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment