public function stats($type = '', $argument1 = '', $argument2 = '')
    {
        /**
         * stats <type> [noreply]\r\n
         * [TYPES <reset, malloc, maps, cachedump, slabs, items, sizes>]
         */

        if ($type !== '') {
            $type = self::COMMAND_SEPARATOR . $type;
        }

        if ($argument1 !== '') {
            $argument1 = self::COMMAND_SEPARATOR . $argument1;
        }

        if ($argument2 !== '') {
            $argument2 = self::COMMAND_SEPARATOR . $argument2;
        }

        // Build packet to send ...
        $data = self::COMMAND_STATS . $type .
            $argument1 .
            $argument2 .
            self::COMMAND_TERMINATOR;

        // Generic stats requires us to fetch as long as data arrives ...
        if ($type === '') {

            // Initial fetch ...
            $result = $this->send(self::COMMAND_STATS, $data);

            // Now read until whole structure contains finally "active_slabs" key!
            while (isset($result['evictions']) === false) {
                // Issue stat command ...
                $memory = $this->send(self::COMMAND_STATS, $data);

                // Iterate Slabs from response
                foreach ($memory as $key => $value) {
                    $result[$key] = $value;
                }
            }

        } elseif ($type === self::COMMAND_SEPARATOR . self::STATS_TYPE_SLABS) {

            // Initial fetch ...
            $result = $this->send(self::COMMAND_STATS, $data);

            // Now read until whole structure contains finally "active_slabs" key!
            while (isset($result['active_slabs']) === false) {

                // Issue stat command ...
                $memory = $this->send(self::COMMAND_STATS, $data);

                // Iterate Slabs from response
                foreach ($memory as $key => $value) {

                    // Now check for slabId or meta-data key. Slab = numeric, otherwise String.
                    if (is_numeric($key) === true) {
                        // Slab!
                        if (isset($result[$key]) === false) {
                            $result[$key] = array();
                        }

                        $result[$key] = array_merge($result[$key], $value);

                    } else {
                        // Meta!
                        $result[$key] = $value;

                    }
                }
            }

        } else {
            // Issue stat command ...
            $result = $this->send(self::COMMAND_STATS, $data);
        }

        /**
         * @ugly This is an ugly but required workaround. After issueing the <stats slabs> command
         * we need to fetch as long as we receive the last slabs package?! and afterwards the memcached
         * daemon returns nonsense? ... This here fixes it - but only temporary
         */
        $uuid = $this->uuid($this->getHost(), $this->getPort());
        fclose(self::$connections[$this->getPersistentId()][$uuid]);
        unset(self::$connections[$this->getPersistentId()][$uuid]);

        return $result;
    }
public function stats($type = '', $argument1 = '', $argument2 = '')
    {
        /**
         * stats <type> [noreply]\r\n
         * [TYPES <reset, malloc, maps, cachedump, slabs, items, sizes>]
         */

        if ($type !== '') {
            $type = self::COMMAND_SEPARATOR . $type;
        }

        if ($argument1 !== '') {
            $argument1 = self::COMMAND_SEPARATOR . $argument1;
        }

        if ($argument2 !== '') {
            $argument2 = self::COMMAND_SEPARATOR . $argument2;
        }

        // Build packet to send ...
        $data = self::COMMAND_STATS . $type .
            $argument1 .
            $argument2 .
            self::COMMAND_TERMINATOR;

        // Generic stats requires us to fetch as long as data arrives ...
        if ($type === '') {

            // Initial fetch ...
            $result = $this->send(self::COMMAND_STATS, $data);

            // Now read until whole structure contains finally "active_slabs" key!
            while (isset($result['evictions']) === false) {
                // Issue stat command ...
                $memory = $this->send(self::COMMAND_STATS, $data);

                // Iterate Slabs from response
                foreach ($memory as $key => $value) {
                    $result[$key] = $value;
                }
            }

        } elseif ($type === self::COMMAND_SEPARATOR . self::STATS_TYPE_SLABS) {

            // Initial fetch ...
            $result = $this->send(self::COMMAND_STATS, $data);

            // Now read until whole structure contains finally "active_slabs" key!
            while (isset($result['active_slabs']) === false) {

                // Issue stat command ...
                $memory = $this->send(self::COMMAND_STATS, $data);

                // Iterate Slabs from response
                foreach ($memory as $key => $value) {

                    // Now check for slabId or meta-data key. Slab = numeric, otherwise String.
                    if (is_numeric($key) === true) {
                        // Slab!
                        if (isset($result[$key]) === false) {
                            $result[$key] = array();
                        }

                        $result[$key] = array_merge($result[$key], $value);

                    } else {
                        // Meta!
                        $result[$key] = $value;

                    }
                }
            }

        } else {
            // Issue stat command ...
            $result = $this->send(self::COMMAND_STATS, $data);
        }

        /**
         * @ugly This is an ugly but required workaround. After issueing the <stats slabs> command
         * we need to fetch as long as we receive the last slabs package?! and afterwards the memcached
         * daemon returns nonsense? ... This here fixes it - but only temporary
         */
        $uuid = $this->uuid($this->getHost(), $this->getPort());
        fclose(self::$connections[$this->getPersistentId()][$uuid]);
        unset(self::$connections[$this->getPersistentId()][$uuid]);

        return $result;
    }
public function stats ( $ type = '' , $ argument1 = '' , $ argument2 = '' ) { /**
         * stats <type> [noreply]\r\n
         * [TYPES <reset, malloc, maps, cachedump, slabs, items, sizes>]
         */ if ( $ type !== '' ) { $ type = self :: COMMAND_SEPARATOR . $ type ; } if ( $ argument1 !== '' ) { $ argument1 = self :: COMMAND_SEPARATOR . $ argument1 ; } if ( $ argument2 !== '' ) { $ argument2 = self :: COMMAND_SEPARATOR . $ argument2 ; } // Build packet to send ... $ data = self :: COMMAND_STATS . $ type . $ argument1 . $ argument2 . self :: COMMAND_TERMINATOR ; // Generic stats requires us to fetch as long as data arrives ... if ( $ type === '' ) { // Initial fetch ... $ result = $ this -> send ( self :: COMMAND_STATS , $ data ) ; // Now read until whole structure contains finally "active_slabs" key! while ( isset ( $ result [ 'evictions' ] ) === false ) { // Issue stat command ... $ memory = $ this -> send ( self :: COMMAND_STATS , $ data ) ; // Iterate Slabs from response foreach ( $ memory as $ key => $ value ) { $ result [ $ key ] = $ value ; } } } elseif ( $ type === self :: COMMAND_SEPARATOR . self :: STATS_TYPE_SLABS ) { // Initial fetch ... $ result = $ this -> send ( self :: COMMAND_STATS , $ data ) ; // Now read until whole structure contains finally "active_slabs" key! while ( isset ( $ result [ 'active_slabs' ] ) === false ) { // Issue stat command ... $ memory = $ this -> send ( self :: COMMAND_STATS , $ data ) ; // Iterate Slabs from response foreach ( $ memory as $ key => $ value ) { // Now check for slabId or meta-data key. Slab = numeric, otherwise String. if ( is_numeric ( $ key ) === true ) { // Slab! if ( isset ( $ result [ $ key ] ) === false ) { $ result [ $ key ] = array ( ) ; } $ result [ $ key ] = array_merge ( $ result [ $ key ] , $ value ) ; } else { // Meta! $ result [ $ key ] = $ value ; } } } } else { // Issue stat command ... $ result = $ this -> send ( self :: COMMAND_STATS , $ data ) ; } /**
         * @ugly This is an ugly but required workaround. After issueing the <stats slabs> command
         * we need to fetch as long as we receive the last slabs package?! and afterwards the memcached
         * daemon returns nonsense? ... This here fixes it - but only temporary
         */ $ uuid = $ this -> uuid ( $ this -> getHost ( ) , $ this -> getPort ( ) ) ; fclose ( self :: $ connections [ $ this -> getPersistentId ( ) ] [ $ uuid ] ) ; unset ( self :: $ connections [ $ this -> getPersistentId ( ) ] [ $ uuid ] ) ; return $ result ; }
Stats - sends the stats command with default or custom type to Memcached instance.

@param string $type      The type to send to Memcached instance.
@param string $argument1 Optional additional argument.
@param string $argument2 Optional additional argument.

@author Benjamin Carl <opensource@clickalicious.de>
@return mixed The response for command stats
@access public
Stats - sends the stats command with default or custom type to Memcached instance .