熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> MySQL >> 正文

教你使用MySQL觸發器自動更新Memcache[2]

2022-06-13   來源: MySQL 

  以下測試腳本摘自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:);

[]  []  


From:http://tw.wingwit.com/Article/program/MySQL/201311/29587.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.