Google App Engine的交点 [英] Intersection on Google App Engine

查看:124
本文介绍了Google App Engine的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户Facebook连接到我的网站时,我想缩小用户的Facebook朋友的列表,只是那些已经注册了我的网站的用户。

When a user Facebook Connects to my site, I want to narrow down the list of the user's Facebook friends to just those that have already signed up for my website.

所以我有两个列表


  • 用户的Facebook朋友的代码列表(大约1000)

  • 已注册我的网站的所有FB用户的GAE表(大约1000)

是最有效的方式这个对所有注册的FB用户的UID进行单一查询,并在代码中做交集?

Is the most efficient way to do this to do a single query for the UIDs of all signed up FB users and do the intersection in code?

如果有更多的10,000个FB用户注册了他们不能全部被< 30秒?

What would be the most efficient way if there were more like 10,000 FB users signed up where they couldn't all be retrieved by queries in < 30 seconds?

推荐答案

稍微转动问题。当用户登录时,获取他的朋友列表,并将facebook数字ids存储在用户对象的列表属性中。 (您也可以使用索引对象...查看 Brett的讲话Slatkin 在GAE中做扇动。)

Turn the problem around on it's head slightly. When a user logs in, fetch his friends list and store the facebook numeric ids in an list property on the user's object. (You could also use an index object... look at the talk by Brett Slatkin on doing fan-out in GAE.)

class User:
  friend_ids = db.ListProperty()

新用户登录,只需在 friend_ids =:id 上进行查询和过滤。这应该会提供您当前用户的朋友的现有用户的列表。我相信其实是你想要的。

When a new user logs in, just do a query and filter on friend_ids = :id. This should give you a list of existing users who are friends of your current user. Which I believe is actually what you want.

如果您在列表中包含要查询的id,则列表属性中过滤的用户查询将返回一个用户,以防您不熟悉。文件是此处

The user query filtered on a list property will return a user if the id you're querying for is contained in the list, in case you're not familiar with that. Docs are here.

这篇关于Google App Engine的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆