四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

用mysql觸發器自動更新memcache的實現代碼

mysql 5.1支持觸發器以及自定義函數接口(UDF)的特性,如果配合libmemcache以及Memcached Functions for MySQL,就能夠實現memcache的自動更新。簡單記錄一下安裝測試步驟。

安裝步驟

  • 安裝memcached,這個步驟很簡單,隨處可見
  • 安裝mysql server 5.1RC,安裝辦法也很大眾,不廢話了
  • 編譯libmemcached,解壓后安裝即可
    ./configure; make; make install
  • 編譯Memcached Functions for MySQL,在http://download.tangent.org/找一個最新的版本下載就是,
    ./configure --with-mysql=/usr/local/mysql/bin/mysql_config --libdir=/usr/local/mysql/lib/mysql/
    make
    make install
    接下來有兩個辦法讓Memcached Functions for MySQL在mysql中生效

     

  • 在mysql的shell中執行memcached_functions_mysql源碼目錄下的sql/install_functions.sql,這會把memcache function作為UDF加入mysql
  • 運行memcached_functions_mysql源碼目錄下的utils/install.pl,這是一個perl腳本,作用同上一條


測試memcache function
以下測試腳本摘自memcached_functions_mysql的源碼目錄,有興趣可以試試

drop table if exists urls;
create table urls (
 
id int(3) not null,
 
url varchar(64) 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');

php技術用mysql觸發器自動更新memcache的實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 又大又肥又圆的白屁股| 爱人的眼睛是第八大洋什么意思?| 情侣不雅视频| 小数除法竖式50道带答案| 西野翔电影| kaori全部av作品大全| 爱上特种兵电视剧免费观看完整版 | 服务群众方面整改成效| 黑丝高跟鞋美女| 动力机甲图片| 法尔| 大众故事1974意大利| 李顺大造屋| 伦理电影在线看| 难兄难弟 电视剧| 宇宙奇趣录| 香港九龙图库精选资料| 宝宝乐园| 麻花影业| 新爱情乐园| 黄色网址在线播放| 斯维特拜克之歌| 张开泰演过的电视剧| 《致命弯道3》| 牛牛电影| 金顶神功| 爱在西元前简谱| 优秀范文| 求职者| 风俗通| 好看的国产动漫| 徐荣柱| 三夫 电影| 大内低手电视剧在线观看| 第一财经在线直播今日股市| 恋爱中的女人 电影| 拼音表大全图| 电影《一秒钟》完整版| 拷打| footjob videos| a面b面|