Merge "Slight improvements to FormSpecialPage behavior."
[lhc/web/wiklou.git] / includes / objectcache / MemcachedClient.php
index 0d96ed6..e5f60b5 100644 (file)
@@ -55,9 +55,9 @@
  *              'compress_threshold' => 10240,
  *              'persistent' => true));
  *
- * $mc->add('key', array('some', 'array'));
- * $mc->replace('key', 'some random string');
- * $val = $mc->get('key');
+ * $mc->add( 'key', array( 'some', 'array' ) );
+ * $mc->replace( 'key', 'some random string' );
+ * $val = $mc->get( 'key' );
  *
  * @author  Ryan T. Dean <rtdean@cytherianage.net>
  * @version 0.1.2
@@ -329,7 +329,7 @@ class MWMemcached {
                        $this->stats['delete'] = 1;
                }
                $cmd = "delete $key $time\r\n";
-               if( !$this->_fwrite( $sock, $cmd ) ) {
+               if ( !$this->_fwrite( $sock, $cmd ) ) {
                        return false;
                }
                $res = $this->_fgets( $sock );
@@ -489,17 +489,17 @@ class MWMemcached {
                        }
                        $key = is_array( $key ) ? $key[1] : $key;
                        if ( !isset( $sock_keys[$sock] ) ) {
-                               $sock_keys[ intval( $sock ) ] = array();
+                               $sock_keys[intval( $sock )] = array();
                                $socks[] = $sock;
                        }
-                       $sock_keys[ intval( $sock ) ][] = $key;
+                       $sock_keys[intval( $sock )][] = $key;
                }
 
                $gather = array();
                // Send out the requests
                foreach ( $socks as $sock ) {
                        $cmd = 'gets';
-                       foreach ( $sock_keys[ intval( $sock ) ] as $key ) {
+                       foreach ( $sock_keys[intval( $sock )] as $key ) {
                                $cmd .= ' ' . $key;
                        }
                        $cmd .= "\r\n";
@@ -733,7 +733,7 @@ class MWMemcached {
                $sock = false;
                $timeout = $this->_connect_timeout;
                $errno = $errstr = null;
-               for( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) {
+               for ( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) {
                        wfSuppressWarnings();
                        if ( $this->_persistent == 1 ) {
                                $sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout );
@@ -810,7 +810,7 @@ class MWMemcached {
                        $bu = array();
                        foreach ( $this->_servers as $v ) {
                                if ( is_array( $v ) ) {
-                                       for( $i = 0; $i < $v[1]; $i++ ) {
+                                       for ( $i = 0; $i < $v[1]; $i++ ) {
                                                $bu[] = $v[0];
                                        }
                                } else {
@@ -822,7 +822,7 @@ class MWMemcached {
                }
 
                $realkey = is_array( $key ) ? $key[1] : $key;
-               for( $tries = 0; $tries < 20; $tries++ ) {
+               for ( $tries = 0; $tries < 20; $tries++ ) {
                        $host = $this->_buckets[$hv % $this->_bucketcount];
                        $sock = $this->sock_to_host( $host );
                        if ( is_resource( $sock ) ) {
@@ -912,7 +912,7 @@ class MWMemcached {
                while ( 1 ) {
                        $decl = $this->_fgets( $sock );
 
-                       if( $decl === false ) {
+                       if ( $decl === false ) {
                                /*
                                 * If nothing can be read, something is wrong because we know exactly when
                                 * to stop reading (right after "END") and we return right after that.
@@ -1123,7 +1123,7 @@ class MWMemcached {
        function _fwrite( $sock, $buf ) {
                $bytesWritten = 0;
                $bufSize = strlen( $buf );
-               while ( $bytesWritten < $bufSize  ) {
+               while ( $bytesWritten < $bufSize ) {
                        $result = fwrite( $sock, $buf );
                        $data = stream_get_meta_data( $sock );
                        if ( $data['timed_out'] ) {