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>
"xxx-rank-5" --> { 1000s, array(...) } // invalidated<br>
"xxx-rank-20" --> { 1080s, array(...) } // valid<br>
"xxx-rank-123" --> { 900s, array(...) } // invalidated<br>
"xxx-name-500" --> { 1040s, array(...) } // valid<br>
....etc<br>
<br>
# meta-entries<br>
"group-xxx-rank" --> { 1050s }<br>
"group-xxx-name" --> { 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 "get" 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> <<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>> 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.' ...<br>
</blockquote></div>