<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On Sep 20, 2007, at 12:10 , K J wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; ">How about storing the list of the user's friends in cache also?  The only problem here though, is what if the user has tens of thousands of friends, for instance?</span></blockquote></div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Bah, just declare that user to be a liar and kick them out of your system.  :)</div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>I just did some hand-wavy math on that:<br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><div>&gt;&gt;&gt; import random</div><div>&gt;&gt;&gt; r=random.Random()</div><div>&gt;&gt;&gt; import sets</div><div>&gt;&gt;&gt; s=sets.Set([r.randint(1, 10000000) for x in range(30000)])</div><div>&gt;&gt;&gt; len(s)</div><div>29950</div><div>&gt;&gt;&gt; len(','.join([str(i) for i in s]))</div><div>236301</div><div>&gt;&gt;&gt; import zlib</div><div><div>&gt;&gt;&gt; compressed=zlib.compress(','.join([str(i) for i in s]), 9)</div><div>&gt;&gt;&gt; len(compressed)</div><div>109568</div><br></div></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>So, a user with about 30k friends with numeric IDs fairly even distributed from 1 to 10,000,000 (my average ID was 4,979,961, min was 236, max was 9,999,931) would take a little over 100k of cache when comma separated and compressed.</div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>I would expect the normal case to be much smaller.<br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>-- </div><div>Dustin Sallings</div><br class="Apple-interchange-newline"></span> </div><br></body></html>