MySQL 5.1 supports triggers and the features of the Custom Function interface (UDF), which, if mated with Libmemcache and memcached Functions for MySQL, enables automatic memcache updates. Simply record the installation test steps.
Installation steps
- Install memcached, this step is very simple, everywhere
- Install MySQL server 5.1RC, installation method is also very popular, no nonsense
- Compile libmemcached, install after decompression
./configure; make; make install
- Compile memcached Functions for MySQL, find a latest version of the download in http://download.tangent.org/is,
./configure --with-mysql=/usr/local/mysql/bin/mysql_config --libdir=/usr/local/mysql/lib/mysql/
make
make install
Then there are two ways to make memcached Functions for MySQL in MySQL.
- Execute the Sql/install_functions.sql in the Memcached_functions_mysql source directory in the MySQL shell, which will add Memcache function as a UDF to MySQL
- Run the Memcached_functions_mysql source directory under the utils/install.pl, this is a Perl script, the role of a
Test Memcache function
The following test scripts are excerpted from the source directory of Memcached_functions_mysql and are interested to try
Drop Table if exists URLs ;
Create Table URLs (
ID int ( 3 ) not NULL ,
URL varchar ( - ) not NULL default '' ,
Primary Key ( ID )
) ;
Select Memc_servers_set ( ' localhost:11211 ' ) ;
Select Memc_set ( ' urls:sequence ' , 0 ) ;
DELIMITER
DROP TRIGGER IF EXISTS Url_mem_insert ;
CREATE TRIGGER Url_mem_insert
before INSERT on URLs
for each ROW BEGIN
SET NEW . ID = memc_increment ( ' urls:sequence ' ) ;
SET @ mm = Memc_set ( concat ( ' URLs: ' , NEW . ID ) , NEW . URL ) ;
END
DELIMITER ;
Insert into URLs ( URL ) Values ( ' http://google.com ' ) ;
Insert into URLs ( URL ) Values ( ' http://www.ooso.net/index.php ' ) ;
Insert into URLs ( URL ) Values ( ' http://www.ooso.net/ ' ) ;
Insert into URLs ( URL ) Values ( ' http://slashdot.org ' ) ;
Insert into URLs ( URL ) Values ( ' http://mysql.com ' ) ;
Select * from URLs ;
Select Memc_get ( ' urls:1 ' ) ;
Select Memc_get ( ' Urls:2 ' ) ;
Select Memc_get ( ' Urls:3 ' ) ;
Select Memc_get ( ' urls:4 ' ) ;
Select Memc_get ( ' Urls:5 ' ) ;
http://www.bkjia.com/PHPjc/320793.html www.bkjia.com true http://www.bkjia.com/PHPjc/320793.html techarticle MySQL 5.1 supports triggers and the features of the Custom Function interface (UDF), which, if mated with Libmemcache and memcached Functions for MySQL, enables automatic memcache updates. Simple Record ...