如何记忆这些数据?

SELECT a.* b.* c.*
FROM TOPIC a, BOARD b, MSGS c
WHERE c.MessageID = 1 AND a.TopicID = c.MessageID AND b.BoardID = c.BoardID

How to memcache this data?

set_cache("MY_WACKY_QUERY_1", data) note: 1 is the message id

Now there are lots of places in the code which update these 3 tables (independantly of each other), so we need to del_cache("XXX_1"); whenever any of these updates and inserts affect MSGS, TOPIC, or BOARD data for, or relating to, the message with id 1

Is there an easy solution?

You can't delete data from memcached without knowing the exact cache key that was used to store it. There is no "index" or "key list" from which you can search for stored data.

One solution might be to make your cache lifetimes short enough so that stale data is mostly a non-concern.

Or maybe... I think I'm confused. To me, it kinda looks like you can do this.

<?php

$memcache = new Memcache;
$memcache->connect( 'memcache_host', 11211 );

// do select query here, store into $result

$memcache->set( 'MY_QUERY_1', $result, false, 600 );

// do another select query here, store into $result

$memcache->set( 'MY_QUERY_2', $result, false, 600 );

// Query here updates record with id of 1

$memcache->delete( 'MY_QUERY_1' );