Re: memcache commands and behavior Hi,
Here another tricks... Mysql triggers and Memcache
Mysql has certain user defined function that interactive with memcache.here how to automative the cache maintenance by calling these functions from triggers.
This all requires running MySQL 5 with dynamically loaded UDF code -- but of course you don't have to upgrade the whole database farm to MySQL 5, just a single replication slave to run the triggers. On this one slave, create AFTER DELETE and AFTER UPDATE triggers that will delete a record from memcache whenever it gets changed or deleted in the database, like this: CREATE trigger cache_expire_delete AFTER DELETE on table1 FOR EACH ROW DO memcache_delete("memcache_host:11211",OLD.pk) ; Here are the details.
First, build Sean Chittenden's libmemcache. (On a GNUish operating system, you need to use BSD make rather than GNU make for this). Then build Jan's UDF (there are notes on doing this in my previous post), and place the udf_memcache.so loadable shared object file into /usr/local/lib/.
Next, log into a dynamically-linked MySQL server (e.g. the mysql-max distribution) as root, and execute Jan's create-function-memcache script. The script contains four CREATE FUNCTION statements, like this: CREATE FUNCTION memcache_delete RETURNS INTEGER SONAME 'udf_memcache.so';
CREATE FUNCTION memcache_set RETURNS INTEGER SONAME 'udf_memcache.so';
CREATE FUNCTION loads in the shared object file, links the SQL function to the UDF code, and creates a record in the mysql.func system table. If you get error 1126 here, it means that the server could not find the .so file.
Thanks,
Prasath.K |