def add_to_redis(content, through, keys):
"""Add content to a list of Redis ordered sets.
:param content: Content object to add
:param through: Content through object. For example on shares, this is the linked share content object
:param keys: List of keys to add to
"""
if not keys:
return
r = get_redis_connection()
for key in keys:
# Only add if not in the set already
# This stops shares popping up more than once, for example
if not r.zrank(key, content.id):
r.zadd(key, int(time.time()), content.id)
r.hset(BaseStream.get_throughs_key(key), content.id, through.id)
评论列表
文章目录