streams.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:socialhome 作者: jaywink 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号