您的位置:首页 > 数据库 > Memcache

PHP + pthreads + memcached

2015-03-30 11:26 169 查看
<?php

class Test extends Thread {

protected static $memcache;

public function run() {

self::$memcache = new Memcache;

if (!self::$memcache->connect('127.0.0.1',11211 ))

throw new Exception("Could not connect");

self::$memcache->set('test', '125', MEMCACHE_COMPRESSED, 50);

$val = self::$memcache->get('test');

echo "Value $val.\n";

}

}

$threads = [];

for ($t = 0; $t < 5; $t++) {

$threads[$t] = new Test();

$threads[$t]->start();

}

for ($t = 0; $t < 5; $t++) {

$threads[$t]->join();

}

var_dump($threads);

感谢原作者:http://stackoverflow.com/questions/22978916/php-pthread-memcache-trouble
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: