One thing that we do is store collections in multiple keys. <br><br>For example we keep a collection of all users currently running the latest release. This collection has about 30,000 items. We have a set of numbered keys "release_user_00" through "release_user_99" that each contain a comma separated list of ids. We take the id of the user module 100 and store the id into the corresponding key. Makes it relatively lightweight to update the date, and easy to pull down the entire set as necessary.
<br><br>We use this approach for handling sets of objects in several parts of our system.<br><br>Chris<br><br><br><div><span class="gmail_quote">On 7/5/07, <b class="gmail_sendername">Steve Grimm</b> <<a href="mailto:email@example.com">
firstname.lastname@example.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 7/5/07 5:12 AM, "Paul Stacey" <<a href="mailto:email@example.com">
firstname.lastname@example.org</a>> wrote:<br>> Events contains an array of event<br><br>A better way to deal with this kind of thing is with a two-phase fetch. So<br>instead of directly caching an array of event data, instead cache an array
<br>of event IDs. Query that list, then use it construct a list of the keys of<br>individual event objects you want to fetch, then multi-get that list of<br>keys.<br><br>In addition to greatly increasing the maximum size of the list (memcached
<br>has a 1-megabyte hard limit on item size, and obviously you can fit a lot<br>more IDs than full data in that limit) you will also, if you're using<br>multiple memcached servers, spread the load around by virtue of your
<br>multi-get hitting basically every server once your key list is a certain<br>size. If you stick all the data in one frequently-requested item, then you<br>will pound the particular server that happened to get that item while all
<br>the others sit idle.<br><br>Another advantage of a scheme like this is that you can update an item's<br>data without having to read then write every list that contains that item.<br>Just update it by ID (like you'd do in your database queries) and all the
<br>lists that contain it will magically get the correct information.<br><br>All the above said, it is true that dealing with lists of things is not<br>currently memcached's strong suit. For example, there is no "append"
<br>operation. It is much better at caching individual objects.<br><br>-Steve<br><br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://avatars.imvu.com/chris">http://avatars.imvu.com/chris</a>