2023-05-12 开启多语言插件支持……

PHP关键字匹配服务器:libra-server

Linux 苏 demo 2499℃ 0评论

libra-server 是一个关键字匹配服务器。为什么需要关键字匹配服务器?你可能想用正则去匹配,不过细想一下,如果有10万个关键字,那不是要用正则匹配10万次。

而是用关键字匹配服务器只需要匹配一次即可,速度非常快,速度只跟你要匹配的原文长度有关。

#安装方法#

1.安装libevent(http://monkey.org/~provos/libevent/)
2.安装libdatrie(http://linux.thai.net/~thep/datrie/datrie.html)
3.make

PHP接口:

存储

1
2
3
4
5
6
7
8
<?php
include('matcher.php');
 
$matcher = new Matcher('192.168.10.20');
$matcher->set('hello');
$matcher->set('world');
$matcher->set('kitty');
?>

 
匹配

1
2
3
4
5
6
7
8
9
<?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 
)
打赏

转载请注明:苏demo的别样人生 » PHP关键字匹配服务器:libra-server

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)