数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

教你使用MySQL触发器自动更新Memcache[2]


发布日期:2021年02月10日
 
教你使用MySQL触发器自动更新Memcache[2]

以下测试脚本摘自memcached_functions_mysql的源码目录有兴趣可以试试

PLAIN TEXTCODE: drop table if exists urls;

create table urls (

id int() not null

url varchar() not null default

primary key (id)

);

select memc_servers_set(localhost:);

select memc_set(urls:sequence );

DELIMITER |

DROP TRIGGER IF EXISTS url_mem_insert;

CREATE TRIGGER url_mem_insert

BEFORE INSERT ON urls

FOR EACH ROW BEGIN

SET NEWid= memc_increment(urls:sequence);

SET @mm= memc_set(concat(urls:NEWid) NEWurl);

END |

DELIMITER ;

insert into urls (url) values (http://googlecom);

insert into urls (url) values (http://wwwoosonet/indexphp);

insert into urls (url) values (http://wwwoosonet/);

insert into urls (url) values (http://slashdotorg);

insert into urls (url) values (http://mysqlcom);

select * from urls;

select memc_get(urls:);

select memc_get(urls:);

select memc_get(urls:);

select memc_get(urls:);

select memc_get(urls:);

[] []

               

上一篇:教你使用MySQL触发器自动更新Memcache[1]

下一篇:SQLSERVER 创建索引实现代码