开发者

Intersection on Google App Engine

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.

So I have two lists

  • A list in code of a user's facebook friends (around 1000)
  • A GAE table of all FB users that have signed up for my site (around 1000)

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?

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开发者_如何学JAVA?


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.)

Something like

class User:
  friend_ids = db.ListProperty()

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜