コード例 #1
0
	public function execute() {
		global $wgMemCachedServers;

		$iterations = $this->getOption( 'i', 100 );
		if( $this->hasArg() )
			$wgMemCachedServers = array( $this->getArg() );

		foreach ( $wgMemCachedServers as $server ) {
			$this->output( $server . " " );
			$mcc = new MemCachedClientforWiki( array('persistant' => true) );
			$mcc->set_debug(true);
			$mcc->set_servers( array( $server ) );
			$set = 0;
			$incr = 0;
			$get = 0;
			$time_start = $this->microtime_float();
			for ( $i=1; $i<=$iterations; $i++ ) {
				if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
					$set++;
				}
			}
			for ( $i=1; $i<=$iterations; $i++ ) {
				if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
					$incr++;
				}
			}
			for ( $i=1; $i<=$iterations; $i++ ) {
				$value = $mcc->get( "test$i" );
				if ( $value == $i*2 ) {
					$get++;
				}
			}
			$exectime = $this->microtime_float() - $time_start;

			$this->output( "set: $set   incr: $incr   get: $get time: $exectime\n" );
		}
	}
コード例 #2
0
 /**
  * @param $debug bool
  */
 public function setDebug($debug)
 {
     $this->client->set_debug($debug);
 }
コード例 #3
0
function &getMemc()
{
    global $wgSessionMemCachedServers, $wgMemc, $wgSessionMemc;
    global $wgMemCachedPersistent, $wgMemCachedDebug;
    if (!empty($wgSessionMemCachedServers) && is_array($wgSessionMemCachedServers) && class_exists('MemcachedClientforWiki')) {
        if (!empty($wgSessionMemc) && is_object($wgSessionMemc) && $wgSessionMemc instanceof MemCachedClientforWiki) {
            return $wgSessionMemc;
        } else {
            $wgSessionMemc = new MemCachedClientforWiki(array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500));
            $wgSessionMemc->set_servers($wgSessionMemCachedServers);
            $wgSessionMemc->set_debug($wgMemCachedDebug);
            return $wgSessionMemc;
        }
    } else {
        return $wgMemc;
    }
}