Merge "Added result properties to action=paraminfo"
[lhc/web/wiklou.git] / maintenance / purgeStaleMemcachedText.php
1 <?php
2 /**
3 * @ingroup Maintenance Memcached
4 * @file
5 */
6
7 require_once( dirname( __FILE__ ) . '/commandLine.inc' );
8
9 function purgeStaleMemcachedText() {
10 global $wgMemc, $wgDBname;
11 $db = wfGetDB( DB_MASTER );
12 $maxTextId = $db->selectField( 'text', 'max(old_id)' );
13 $latestReplicatedTextId = $db->selectField( array( 'recentchanges', 'revision' ), 'rev_text_id',
14 array( 'rev_id = rc_this_oldid', "rc_timestamp < '20101225183000'"), 'purgeStaleMemcachedText',
15 array( 'ORDER BY' => 'rc_timestamp DESC' ) );
16 $latestReplicatedTextId -= 100; # A bit of paranoia
17
18 echo "Going to purge text entries from $latestReplicatedTextId to $maxTextId in $wgDBname\n";
19
20 for ( $i = $latestReplicatedTextId; $i < $maxTextId; $i++ ) {
21 $key = wfMemcKey( 'revisiontext', 'textid', $i );
22
23 while (1) {
24 if (! $wgMemc->delete( $key ) ) {
25 echo "Memcache delete for $key returned false\n";
26 }
27 if ( $wgMemc->get( $key ) ) {
28 echo "There's still content in $key!\n";
29 } else {
30 break;
31 }
32 }
33
34 }
35 }
36
37 purgeStaleMemcachedText();
38