def rcmd_from_queue(uid): '''从优先队列里进行推荐''' key = keys.FIRST_RCMD_Q % uid uid_list = rds.lrange(key, 0, 19) # 从Redis 取出 优先推荐的用户 ID # 这里取出来的都是 bytes 类型的数据, 还需要强转成 int uid_list = [int(r_uid) for r_uid in uid_list] # 将uid 列表元素 return User.objects.filter(id__in=uid_list)
def rcmd_from_queue(uid): '''优先从喜欢我的人队列里面进行推荐''' uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19) # 从优先推荐队列取出uid列表 # lrange是redis的获取数据 # 左避右避 uid_list = [int(uid) for uid in uid_list] # 将二进制uid强转成int类型 return User.objects.filter(id__in=uid_list)
def rcmd_from_queue(uid): '''从推荐列表进行推荐''' # 结果是2进制列表,取20个 uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19) # 转换成int类型 uid_list = [int(uid) for uid in uid_list] users = User.objects.filter(id__in=uid_list) return users
def rcmd_from_queue(uid): '''从优先推荐队列进行推荐''' uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19) # 从优先推荐队列取出 uid 列表 uid_list = [int(uid) for uid in uid_list] # 将 uid 强转成 int 类型 return User.objects.filter(id__in=uid_list)
def rcmd_from_rds(uid): '''取出优先推荐队列的用户''' uid_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 29) uid_list = [int(uid) for uid in uid_list] return User.objects.filter(id__in=uid_list)
def first_rcmd(uid): """从Redis的优秀推荐列表中获取要推荐的用户""" uid_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 20) uid_list = [int(uid) for uid in uid_list] # 将uid_list中的bytes强转成int return User.objects.filter(id__in=uid_list)
def rcmd_users_from_q(uid): '''从优先队列中获取推荐对象''' name = keys.FIRST_RCMD_Q % uid uid_list = rds.lrange(name, 0, 24) uid_list = [int(uid) for uid in uid_list] return User.objects.filter(id__in=uid_list)
def rcmd_from_queue(uid): '''从优先推荐队列里推荐用户''' uid_list = rds.lrange(keys.FIRST_RCMD_Q + str(f'{uid}'), 0, 19) # 从优先推荐队列取出uid uid_list = [int(uid) for uid in uid_list] return User.objects.filter(id__in=uid_list)
def first_rcmd(uid): '''从redis的优先推荐列表中获取要推荐的用户''' uid_list = rds.lrange(keys.FIRST_CRMD_K % uid, 0, 19) uid_list = [int(uid) for uid in uid_list] # 将uid_list中的bytes强转成int return User.objects.filter(id__in=uid_list)
def rcmd_from_list(user_id): '''从优先推荐列表取出滑动用户''' uid_list = rds.lrange(keys.PRIOR_RCMD_LIST % user_id, 0, 19) uid_list = [int(uid) for uid in uid_list] # 将bytes类型强转为int类型 users = User.objects.filter(id__in=uid_list) return users
def users_from_rds(uid): """从Redis中提取用户""" user_id_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 19) users = [user for user in User.objects.filter(id__in=user_id_list)] return users