时间:2021-07-01 10:21:17 帮助过:42人阅读
mysql 5.1支持触发器以及自定义函数接口(UDF)的特性,如果配合libmemcache以及Memcached Functions for MySQL,就能够实现 memcache 的自动更新。简单记录一下安装测试步骤。 安装步骤 安装memcached,这个步骤很简单,随处可见 安装mysql server 5.1RC,安装
mysql 5.1支持触发器以及自定义函数接口(UDF)的特性,如果配合libmemcache以及Memcached Functions for MySQL,就能够实现memcache的自动更新。简单记录一下安装测试步骤。
./configure; make; make install
./configure --with-mysql=/usr/local/mysql/bin/mysql_config --libdir=/usr/local/mysql/lib/mysql/
make
make install
以下测试脚本摘自memcached_functions_mysql的源码目录,有兴趣可以试试
drop table if exists urls;
create table urls (
id int(3)notnull,
url varchar(64)notnulldefault'',
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');
作者: Volcano 发表于July 9, 2008 at 2:41 pm
版权信息: 和作者信息及此声明
永久链接 - http://www.ooso.net/archives/436