I got several requests for the code so I'll reply to list. <br><br>I've posted a blog entry with a little more info at <a href="http://www.imvu.com/technology">http://www.imvu.com/technology</a> (<a href="http://www.imvu.com/blogs/index.php?blog=793&title=extensions_to_php_memcached_api">
direct link</a>). I've posted the code at <a href="http://www.imvu.com/technology/memcache.tar.gz">http://www.imvu.com/technology/memcache.tar.gz</a> (also linked from the blog post).<br><br>Chris<br><br>-- <br><a href="http://avatars.imvu.com/chris">
http://avatars.imvu.com/chris</a>
<br><br><br><br><div><span class="gmail_quote">On 6/28/06, <b class="gmail_sendername">Chris Hondl</b> <<a href="mailto:chris@imvu.com">chris@imvu.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;">
<div><br>This problem sounds similar to a problem we've solved with our database query cache. We have many distinct database queries that we cache about a particular entity (user, product, etc.), and we want to flush all of the queries when the underlying data changes.
<br><br>We've solved this problem by wrapping the memcache interface with an extension api to support what we call "cache-class". The api supports assigning any memcache key to a cache-class when get/set/add is called. The api also has a function to flush all the keys associated with a cache-class.
<br><br>This is implemented at the cost of 0-2 extra memcache accesses per operation and requires no chance to the memcache server. The extra accesses are used to maintain a version number associated with each cache-class. The flush call simply increments the version number, and the wrapped get call ignores any data with an old version number.
<br><br>We've had this in production for over two months. Our implementation is in PHP and is pretty self-contained. Be glad to share with anyone interested.<br><br>Chris<br></div><div><span class="sg">-- <br><a href="http://avatars.imvu.com/chris" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://avatars.imvu.com/chris</a>
</span></div><div><span class="e" id="q_10c1ccb81367d0c3_2"><br><br><br><div><span class="gmail_quote">On 6/28/06, <b class="gmail_sendername">NTPT</b> <<a href="mailto:NTPT@seznam.cz" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
NTPT@seznam.cz</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;">
Memcached and two dimensional array<br><br><br>Hi.<br><br>I have folowing situation in my project. I have "user data" identified by "user_id" and object data identified by "object_id"<br><br>
Now i need to render data of the object identified by object_id with settings stored in "user data". This process add a lot of overhead, so it need to be chached with memcached . So i construct key string like this in PHP $key = user_id . "_" . object_id It can cleany lidentify rendered data, it is fine.
<br><br><br>But "user data" and "object data" are changing quite fast. So i need a way to delete all data that are cached for some user, if user data are changed, and all rendered instance of certain object if the object is changed.
<br><br>Like in two dimensional array deleting a whole row or a whole column. Is it possible with memcache ?<br><br>For now, it seems that only way to do is a flush a single key (with is insufficient) or flush entire cache with is too much....
<br><br><br>Thanx for help.<br></blockquote></div><br><br clear="all"><br><br>
</span></div></blockquote></div><br><br clear="all"><br><br>