public function __construct($queueName = '', $maxqueue = 1, $canRewrite = false, $expire = 0, $config = '') { if (empty($config)) { self::$client = memcache_pconnect('127.0.0.1', 11211); } elseif (is_array($config)) { //array('host'=>'127.0.0.1','port'=>'11211') self::$client = memcache_pconnect($config['host'], $config['port']); } elseif (is_string($config)) { //"127.0.0.1:11211" $tmp = explode(':', $config); $conf['host'] = isset($tmp[0]) ? $tmp[0] : '127.0.0.1'; $conf['port'] = isset($tmp[1]) ? $tmp[1] : '11211'; self::$client = memcache_pconnect($conf['host'], $conf['port']); } if (!self::$client) { return false; } ignore_user_abort(true); //当客户断开连接,允许继续执行 set_time_limit(0); //取消脚本执行延时上限 $this->access = false; $this->sleepTime = 1000; $expire = empty($expire) ? 0 : (int) $expire + 1; $this->expire = $expire; $this->queueName = $queueName; $this->retryNum = 20000; $this->MAXNUM = $maxqueue != null ? $maxqueue : 1; $this->canRewrite = $canRewrite; $this->getHeadAndTail(); if (!isset($this->HEAD) || empty($this->HEAD)) { $this->HEAD = 0; } if (!isset($this->TAIL) || empty($this->TAIL)) { $this->TAIL = 0; } if (!isset($this->LEN) || empty($this->LEN)) { $this->LEN = 0; } }