qq_31825139 2016-07-28 07:38 采纳率: 0%
浏览 956

自己写的一个memcache 的小程序,但是总是不能实例化,安装好扩展。求解

<?php
define('DIR',__DIR__);
include DIR .'/Common/Loder.php';
spl_autoload_register('\Common\Loder::autoLoder'); //自动加载类
$database = \Common\Factory::createDatabase('************','root','','memcached_test'); //数据库连接

$memcache = \Common\Factory::addServers('*****',11211); // memcache 服务器地址 端口 如果在这里直接new memcache 是可以的

/**************/
<?php
namespace Common;

class Factory
{
static function createDatabase($localhost, $user, $pwd, $datebase)
{

$db = Register::get($datebase); //从注册器中取出对象
if (!$db) {
$db = new Datebase($localhost, $user, $pwd, $datebase);
Register::set($datebase, $db); //向注册器中注册Datebase
}
return $db;
}

static function addServers($localhost, $port)
{
    $key = $localhost.'_me';
    $db = Register::get($key);   //从注册器中取出对象
    if (!$db) {
        $db = new Me($localhost,$port);
        Register::set($key, $db);  //向注册器中注册Me
    }
    return $db;
}

}
/***************************/
<?php
/**

  • Created by PhpStorm.
  • User: Administrator
  • Date: 2016/7/27
  • Time: 18:39 */

namespace Common;

class Me
{
function __construct($localhost,$port)
{
$m = new Memcache(); // 进入这里 浏览器就会报一个 500 的错误
$m->addServer($localhost,$port);
return $m;
}
}

  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝