Altering queries?

Dustin Sallings dustin at
Thu Sep 20 19:36:59 UTC 2007

On Sep 20, 2007, at 12:10 , K J wrote:

> 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?

	Bah, just declare that user to be a liar and kick them out of your  
system.  :)

	I just did some hand-wavy math on that:

 >>> import random
 >>> r=random.Random()
 >>> import sets
 >>> s=sets.Set([r.randint(1, 10000000) for x in range(30000)])
 >>> len(s)
 >>> len(','.join([str(i) for i in s]))
 >>> import zlib
 >>> compressed=zlib.compress(','.join([str(i) for i in s]), 9)
 >>> len(compressed)

	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.

	I would expect the normal case to be much smaller.

Dustin Sallings

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list