If you use replication with MySQL and memcache at the same time you have the problem to make sure that the memcached and the slave are in sync. If you announce the memcached to mark a entry as dirty and let it update the value from the slave BEFORE it is updated, you fetch a old value.
The easiest way to ensure that memcache is always notified after the slave is updated, you can use ... well ... replication. MySQL 5.1 brings Row Based Replication that makes this kind of applications a lot easier.
I'm not there to present you a Proof of Concept, I'm only close enough to explain the idea:
- Slave fetches records from Master
- Slave applies the records
- Slave exposes its changes as replication stream to the MySQL Proxy
- MySQL Proxy decodes the RBR records, extracts the Primary Key and updates the content in the memcache server
The MySQL Proxy acts as replication client …
[Read more]