Index: trunk/phase3/maintenance/purgeStaleMemcachedFlaggedRevs.php |
— | — | @@ -0,0 +1,39 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once( dirname( __FILE__ ) . '/commandLine.inc' ); |
| 5 | + |
| 6 | +function purgeStaleMemcachedText() { |
| 7 | + global $wgMemc, $wgDBname; |
| 8 | + $db = wfGetDB( DB_MASTER ); |
| 9 | + $maxTextId = $db->selectField( 'text', 'max(old_id)' ); |
| 10 | + $latestReplicatedTextId = $db->selectField( array( 'recentchanges', 'revision' ), 'rev_text_id', |
| 11 | + array( 'rev_id = rc_this_oldid', "rc_timestamp < '20101225183000'"), 'purgeStaleMemcachedText', |
| 12 | + array( 'ORDER BY' => 'rc_timestamp DESC' ) ); |
| 13 | + $latestReplicatedTextId -= 100; # A bit of paranoia |
| 14 | + |
| 15 | + echo "Going to purge text entries from $latestReplicatedTextId to $maxTextId in $wgDBname\n"; |
| 16 | + |
| 17 | + for ( $i = $latestReplicatedTextId; $i < $maxTextId; $i++ ) { |
| 18 | + $keys = array(); |
| 19 | + $keys[] = wfMemcKey( 'flaggedrevs', 'countPending', $i ); |
| 20 | + $keys[] = wfMemcKey( 'flaggedrevs', 'includesSynced', $i ); |
| 21 | + $keys[] = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $i ); |
| 22 | + $keys[] = wfMemcKey( 'unreviewedPages', 'underReview', $i ); |
| 23 | + |
| 24 | + foreach ( $keys as $key ) { |
| 25 | + while (1) { |
| 26 | + if (! $wgMemc->delete( $key ) ) { |
| 27 | + echo "Memcache delete for $key returned false\n"; |
| 28 | + } |
| 29 | + if ( $wgMemc->get( $key ) ) { |
| 30 | + echo "There's still content in $key!\n"; |
| 31 | + } else { |
| 32 | + break; |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +purgeStaleMemcachedText(); |
| 40 | + |