做开发的时候用到了缓存,而在做缓存配置的时候发现现在原来关于store文件配置的说明文档在WorkerMan 3.x 手册没有了( http://doc.workerman.net/start/store_config.html ),找到了一篇之前关于Memcached调用的文章( http://wenda.workerman.net/?/question/69 )却发现按照这样的配置无法调用,报错信息为:
/*------------------------------------------------------------------------------------------------------------------------------
Fatal error: Uncaught Error: Class 'Store' not found in C:\wamp64\www\workerman-
todpole-for-win-master\Applications\Timer\Events.php:82
Stack trace:
#0 : Events::onWorkerStart(Object(GatewayWorker\BusinessWorke
r))
#1 C:\wamp64\www\workerman-todpole-for-win-master\GatewayWorker\BusinessWorker.p
hp(195): call_user_func('Events::onWorke...', Object(GatewayWorker\BusinessWorke
r))
#2 : GatewayWorker\BusinessWorker->onWorkerStart(Object(Gatew
ayWorker\BusinessWorker))
#3 C:\wamp64\www\workerman-todpole-for-win-master\Workerman\Worker.php(741): cal
l_user_func(Array, Object(GatewayWorker\BusinessWorker))
#4 C:\wamp64\www\workerman-todpole-for-win-master\GatewayWorker\BusinessWorker.p
hp(174): Workerman\Worker->run()
#5 C:\wamp64\www\workerman-todpole-for-win-master\Workerman\Worker.php(433): Gat
ewayWorker\BusinessWorker->run()
--------------------------------------------------------------------------------------------------------------------------------*/
而后来我又换了一种方式,直接初始化缓存对象的方式来调用
/*------------------------------------------------------------
//创建memcache对象
$mem = new Memcache;
//连接memcache服务器
$mem -> connect("localhost", 11211);
------------------------------------------------------------*/
结果出现了同样的报错,无法找到Memcached
/*-------------------------------------------------------------------------------------------------------------------------------
Fatal error: Uncaught Error: Class 'Memcache' not found in C:\wamp64\www\workerm
an-todpole-for-win-master\Applications\Timer\Events.php:85
Stack trace:
#0 : Events::onWorkerStart(Object(GatewayWorker\BusinessWorke
r))
#1 C:\wamp64\www\workerman-todpole-for-win-master\GatewayWorker\BusinessWorker.p
hp(195): call_user_func('Events::onWorke...', Object(GatewayWorker\BusinessWorke
r))
#2 : GatewayWorker\BusinessWorker->onWorkerStart(Object(Gatew
ayWorker\BusinessWorker))
#3 C:\wamp64\www\workerman-todpole-for-win-master\Workerman\Worker.php(741): cal
l_user_func(Array, Object(GatewayWorker\BusinessWorker))
#4 C:\wamp64\www\workerman-todpole-for-win-master\GatewayWorker\BusinessWorker.p
hp(174): Workerman\Worker->run()
-----------------------------------------------------------------------------------------------------------------------------*/
想问两个问题:
1.如何正确调用Memcached
如何直接使用php提供的原生的memcache接口
还望worker大大给解答一下
(运行环境:WIN7 64 已安装Memcached扩展且用PHPdemo运行成功。)
这个看PHP手册就行了。workerman里使用memcache redis mysql等扩展没有限制。
http://php.net/manual/zh/book.memcached.php