Localisation updates for core and extension messages from translatewiki.net
[mediawiki.git] / maintenance / purgeStaleMemcachedText.php
blobfc9a6a8947b90e6b88318abae8d5f3b3aca2776d
1 <?php
2 /**
3 * @ingroup Maintenance Memcached
4 * @file
5 */
7 require_once( dirname( __FILE__ ) . '/commandLine.inc' );
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
18 echo "Going to purge text entries from $latestReplicatedTextId to $maxTextId in $wgDBname\n";
20 for ( $i = $latestReplicatedTextId; $i < $maxTextId; $i++ ) {
21 $key = wfMemcKey( 'revisiontext', 'textid', $i );
23 while (1) {
24 if (! $wgMemc->delete( $key ) ) {
25 echo "Memcache delete for $key returned false\n";
27 if ( $wgMemc->get( $key ) ) {
28 echo "There's still content in $key!\n";
29 } else {
30 break;
37 purgeStaleMemcachedText();