Ryan Kanno: The diary of an Enginerd in Hawaii

Everything you’ve ever thought, but never had the balls to say.

Tag Archive » ‘hash-table’

Calling all (Django) programmers… (I need advice)

Update

According to Max, it’s against Facebook’s TOS to cache the data. I’ve totally must’ve skipped over it in the TOS… ok, fine… I admit, I didn’t even read it. Thanks Max! And to think this response was less than an hour after my post! Yay, community. In any case, this problem is still relevant to many a graph-structured sites. Comment on!


Since I don’t know of many techies in Hawaii, I figured I would post a blog in hopes of attracting a solution from the akamai Django community.

The Background

I’m currently writing a Facebook application in Django (which I’ll be blogging about later).

The Problem

I want to be able to programatically tell if you’ve updated your friends in Facebook. Basically, at the end of the day, Facebook provides an API call that allows you to retrieve a list of uid’s that represent your ‘friends’. I’m planning to cache this data within my own system. I was wondering how Pythonic people would solve the following:

Is there a data type or algorithm (or combination thereof) I can use to compare the returned uids with my uid data cache? This comparison algorithm will tell me if you’ve added or subtracted new friends in Facebook. As a bonus, I’d prefer this comparison optimized (for Python).

Possible Solutions

So I’ve sat down and made a list of possible solutions:

  • Creating an in memory hash from my cached data and seeing which Facebook API returned uids collide and which don’t. (EASY)
  • Using SET comparison in MySQL. (EASY)
  • Possibly encoding the uids in a way to optimize the comparison of two sets; though I’d have to research this. (EW)
  • …? (Your input goes here)

Btw, I’d never thought I’d say this, but without CLR, I feel so lost. ;P

Like I wrote in my last post, a few years out of grad school and a bunch of web applications later, and I’m really, really rusty. In any case, feel free to leave any comments/ideas and I’ll be sure to credit you for your solution!

Tagged: , , , , , , .


Powered by Wordpress. Stalk me.