Re: help for memcached Segmentation fault

From: Date: Tue, 28 Jun 2011 03:07:24 +0000
Subject: Re: help for memcached Segmentation fault
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-313770@lists.php.net to get a copy of this message
sorry, the right $config['memcached'] variable is $config['memcached']=array(array('host'=>'localhost', port=11211, persistent=1,weight=1)); 2011/6/28 xucheng <xucheng@sankuai.com>: > Hi all, >       I wrap pecl-memcache into a class used as a sigleton class . > the code is : > > ==================================================code=================================================================================== >       class Mem{ > >        private static $_instance = null ;//singlton object instance > >        private function __construct(){ > >                        global $config ; >                        $servers = $config['memcached'] ; >                        $mem = new Memcache ; >                        foreach($servers as $server){ >                                $mem->addServer($server['host'], > $server['port'], intval($server['persistent']) > 0 ? 1 : 0, > intval($server['weight']) > 0 ? intval($server['weight']) : 1 ) ; >                        } >                        return $mem ; > >        } > >        private static function getInstance(){ > >                        if(self::$_instance === null || !( > self::$_instance instanceof Mem ) ){ > >                                        self::$_instance = new Mem() ; > >                        } > >                        return true ; > >        } > >        public static function get($key){ > >                        self::getInstance() ; >                        return self::$_instance->get(md5(strtolower($key))) ; > >        } > >        public static function set($key, $value, $ttl=0){ >                        self::getInstance() ; >                        $compress = (is_bool($value) || is_int($value) > || is_float($value)) ? false : MEMCACHE_COMPRESSED ; >                        return > self::$_instance->set(md5(strtolower($key)), $value, $compress, $ttl) > ; > >        } > >        public static function rm($key){ >                        self::getInstance() ; >                        return > self::$_instance->delete(md5(strtolower($key)),0) ; >        } > } > > > ===============================================================code========================================================== > > and $config['memcached'] is an array contains info about the server . > $config['memcached'] = array('host'=>'localhost', port=11211, > persistent=1,weight=1) ; > > when i run this , i got "Segmentation fault" ! I cannot figure out > what's the problem . any commet appreciate . > > and i used memcached 1.4.5 , and libevent-1.4.13-1 > php 5.2.16 >

« previous php.general (#313770) next »