How would you deal with entries that depend indirectly on user jsmith?<br>
<br>
A situation I'm trying to solve involves a gallery of up to 50k items
that can be sorted by a limited number of criteria. Memcached could
store each page (of 12 items) as function of order type and page
number. The problem is that whenever any of these items change,
all relevant pages must be invalidated (e.g. pushing an item to rank #1 will invalidate all following pages).<br>
<br>
One approach I'm considering involves 1. adding timestamps for each
cached entry and 2. keeping track of invalidation times for each group:<br>
<br>
# cached entries as function of order and page<br>
&quot;xxx-rank-5&quot; --&gt; { 1000s, array(...) }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // invalidated<br>
&quot;xxx-rank-20&quot; --&gt; { 1080s, array(...) }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // valid<br>
&quot;xxx-rank-123&quot; --&gt; { 900s, array(...) }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // invalidated<br>

&quot;xxx-name-500&quot; --&gt; { 1040s, array(...) }&nbsp;&nbsp; // valid<br>
....etc<br>
<br>
# meta-entries<br>
&quot;group-xxx-rank&quot; --&gt; { 1050s }<br>
&quot;group-xxx-name&quot; --&gt; { 1010s }<br>
<br>
In this scenario, each page load would involve two memcache requests
followed by a timestamp delta check. If invalid, the entry can be replaced
with fresh values.<br>
<br>
Such an approach might emulate the namespaces concept a bit...<br>
<br>
The general problem with this case is that when there are many
changes (e.g. lots of people voting), the effective TTL for each entry
decreases and so does performance.<br>
<br>
Maybe this is a bit of an extreme case though... however, I'm somewhat
curious about the merits of writing a custom storage engine (ab)using
the memcache protocol to return dynamically generated data in response
to &quot;get&quot; requests. This may give many more possibilities for
optimization, especially in those cases where a full-featured RDBMS is
not necessary (e.g. keeping track of visitor activity).<br>
<br>
Regards,<br>
<br>
Serhat<br><br><div><span class="gmail_quote">On 7/27/06, <b class="gmail_sendername">Jacob Coby</b> &lt;<a href="mailto:jcoby@listingbook.com" title="mailto:jcoby@listingbook.com (mailto:jcoby@listingbook.com)" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

jcoby@listingbook.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I
think a lot of that comes from the lack of namespaces in memcached. You
can't just say 'invalidate all cache entries for user jsmith.'&nbsp; ...<br>
</blockquote></div>