国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

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

2024-07-24 12:40:27
字體:
來源:轉載
供稿:網友
不錯的一篇文章,用于項目中可以帶來更多的便利,按照方法已經調試成功,可以大大提高項目的速度。     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');
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉峪关市| 甘肃省| 应用必备| 宾川县| 依兰县| 黑龙江省| 闻喜县| 星座| 南昌县| 潜江市| 崇信县| 高清| 西青区| 洛隆县| 简阳市| 宣恩县| 托克逊县| 双辽市| 大厂| 玉龙| 柘城县| 灵石县| 台山市| 沙田区| 即墨市| 吉林省| 沂水县| 梓潼县| 板桥市| 喀喇沁旗| 安远县| 奉化市| 霸州市| 育儿| 灵川县| 永修县| 商南县| 建湖县| 新宁县| 凤翔县| 吴忠市|