PHP關鍵字匹配服務器:libra-server
libra-server 是一個關鍵字匹配服務器。為什么需要關鍵字匹配服務器?你可能想用正則去匹配,不過細想一下,如果有10萬個關鍵字,那不是要用正則匹配10萬次。
而是用關鍵字匹配服務器只需要匹配一次即可,速度非常快,速度只跟你要匹配的原文長度有關。
#安裝方法#
1.安裝libevent(http://monkey.org/~provos/libevent/)
2.安裝libdatrie(http://linux.thai.net/~thep/datrie/datrie.html)
3.make
PHP接口:
存儲
<?php include('matcher.php'); $matcher = new Matcher('192.168.10.20'); $matcher->set('hello'); $matcher->set('world'); $matcher->set('kitty'); ?>
匹配
<?php include('matcher.php'); $matcher = new Matcher('192.168.10.20'); $matchs = $matcher->gets('hello world, hello kitty') if (!empty($matchs)) { print_r($matchs); } ?>
輸出:
Array ( [hello] => hello [world] => world [kitty] => kitty )
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!