sanbat at gmail.com
Fri Sep 21 06:02:52 UTC 2007
> 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
> I would expect the normal case to be much smaller.
Thinking further on this issue though, gives me more questions...
Storing a list of a user's friends in a Memcache array, then getting them
back in and searching through them... while it avoids the database
altogether, wouldn't it be sorta slow? For instance, every time a user
visits user B's profile page, the system would need to iterate through this
array and see if they are connected.
In this case would it be just better to have a heap mysql database and query
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the memcached