Changeset 800681
- Timestamp:
- 11/07/2013 09:56:39 PM (12 years ago)
- File:
-
- 1 edited
-
memcached-redux/trunk/object-cache.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
memcached-redux/trunk/object-cache.php
r611610 r800681 3 3 Plugin Name: Memcached Redux 4 4 Description: The real Memcached (not Memcache) backend for the WP Object Cache. 5 Version: 0.1.1 5 Version: 0.1.1b 6 6 Plugin URI: http://wordpress.org/extend/plugins/memcached/ 7 7 Author: Scott Taylor - uses code from Ryan Boren, Denis de Bernardy, Matt Martz … … 59 59 * array( 'key' ) 60 60 * ); 61 * 61 * 62 62 */ 63 63 function wp_cache_get_multi( $key_and_groups, $bucket = 'default' ) { … … 72 72 * array( 'key', 'data' ) 73 73 * ); 74 * 74 * 75 75 */ 76 76 function wp_cache_set_multi( $items, $expire = 0, $group = 'default' ) { … … 171 171 $key = $this->key( $id, $group ); 172 172 $mc =& $this->get_mc( $group ); 173 $this->cache[ $key ] = $mc->increment( $key, $n ); 173 $this->cache[ $key ] = $mc->increment( $key, $n ); 174 174 return $this->cache[ $key ]; 175 175 } … … 183 183 184 184 function close() { 185 // Silence is Golden.185 // Silence is Golden. 186 186 } 187 187 … … 204 204 unset( $this->cache[$key] ); 205 205 206 return $result; 206 return $result; 207 207 } 208 208 … … 224 224 if ( isset( $this->cache[$key] ) ) { 225 225 if ( is_object( $this->cache[$key] ) ) 226 $value = clone $this->cache[$key];226 $value = clone $this->cache[$key]; 227 227 else 228 228 $value = $this->cache[$key]; … … 231 231 } else { 232 232 $value = $mc->get( $key ); 233 if ( empty( $value ) || ( is_integer( $value ) && -1 == $value ) )234 $value = false;233 if ( empty( $value ) || ( is_integer( $value ) && -1 == $value ) ) 234 $value = false; 235 235 $this->cache[$key] = $value; 236 236 } … … 286 286 } 287 287 288 function key( $key, $group ) { 288 function key( $key, $group ) { 289 289 if ( empty( $group ) ) 290 290 $group = 'default'; … … 361 361 $mc->setMulti( $sets, $expire ); 362 362 } 363 363 364 364 function colorize_debug_line( $line ) { 365 365 $colors = array( … … 367 367 'set' => 'purple', 368 368 'add' => 'blue', 369 'delete'=> 'red' 370 );369 'delete'=> 'red' 370 ); 371 371 372 372 $cmd = substr( $line, 0, strpos( $line, ' ' ) ); … … 386 386 echo "<h3>Memcached:</h3>"; 387 387 foreach ( $this->group_ops as $group => $ops ) { 388 if ( !isset( $_GET['debug_queries'] ) && 500 < count( $ops ) ) { 389 $ops = array_slice( $ops, 0, 500 ); 388 if ( !isset( $_GET['debug_queries'] ) && 500 < count( $ops ) ) { 389 $ops = array_slice( $ops, 0, 500 ); 390 390 echo "<big>Too many to show! <a href='" . add_query_arg( 'debug_queries', 'true' ) . "'>Show them anyway</a>.</big>\n"; 391 } 391 } 392 392 echo "<h4>$group commands</h4>"; 393 393 echo "<pre>\n"; 394 394 $lines = array(); 395 395 foreach ( $ops as $op ) { 396 $lines[] = $this->colorize_debug_line( $op ); 396 $lines[] = $this->colorize_debug_line( $op ); 397 397 } 398 398 print_r( $lines ); … … 424 424 foreach ( $buckets as $bucket => $servers ) { 425 425 $this->mc[$bucket] = new Memcached(); 426 427 $instances = array();428 foreach ( $servers as $server ) {426 427 $instances = array(); 428 foreach ( $servers as $server ) { 429 429 @list( $node, $port ) = explode( ':', $server ); 430 430 if ( empty( $port ) ) … … 433 433 if ( !$port ) 434 434 $port = 11211; 435 436 $instances[] = array( $node, $port, 1 );435 436 $instances[] = array( $node, $port, 1 ); 437 437 } 438 $this->mc[$bucket]->addServers( $instances );438 $this->mc[$bucket]->addServers( $instances ); 439 439 } 440 440
Note: See TracChangeset
for help on using the changeset viewer.