日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

memcache如何更新mysql_使用MySQL触发器如何实现memcache自动更新

發布時間:2023/12/15 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 memcache如何更新mysql_使用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的源碼目錄,有興趣可以試試

PLAIN TEXTCODE: 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');

標簽:

本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,尊重他人勞動成果

文章轉載自:IT專家網

0

好文不易,鼓勵一下吧!

總結

以上是生活随笔為你收集整理的memcache如何更新mysql_使用MySQL触发器如何实现memcache自动更新的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。