如何在Windows中的wamp中启用memcached?

时间:2013-06-29 09:56:06

标签: php memcached wamp

运行WAMP服务器并启用了php_memcache扩展并尝试了代码

<?php
    $memcache = new Memcache;
    $memcache->connect('localhost', 11211) or die ("Could not connect");

    $version = $memcache->getVersion();
    echo "Server's version: ".$version."<br/>\n";

    $tmp_object = new stdClass;
    $tmp_object->str_attr = 'test';
    $tmp_object->int_attr = 123;

    $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
    echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";

    $get_result = $memcache->get('key');
    echo "Data from the cache:<br/>\n";

    var_dump($get_result);
?>

1 个答案:

答案 0 :(得分:0)

看起来您正在尝试连接MySql服务器而不安装它。首先,您必须安装memcached服务器。您可以在Windows上使用couchbase server with memcache bucket。恕我直言,它是Windows操作系统的最佳端口。