76 $inputDate = $this->getOption(
'expiredate' );
77 $inputAge = $this->getOption(
'age' );
79 if ( $inputDate !==
null ) {
80 $timestamp = strtotime( $inputDate );
81 } elseif ( $inputAge !==
null ) {
82 $expireTime = (int)$this->getConfig()->get( MainConfigNames::ParserCacheExpireTime );
83 $timestamp = time() + $expireTime - intval( $inputAge );
85 $this->fatalError(
"Must specify either --expiredate or --age" );
87 $this->usleep = 1e3 * $this->getOption(
'msleep', 0 );
88 $this->lastTimestamp = microtime(
true );
90 $humanDate = ConvertibleTimestamp::convert( TS_RFC2822, $timestamp );
91 if ( $this->hasOption(
'dry-run' ) ) {
92 $this->fatalError(
"\nDry run mode, would delete objects having an expiry before " . $humanDate .
"\n" );
95 $this->output(
"Deleting objects expiring before " . $humanDate .
"\n" );
97 $pc = $this->getServiceContainer()->getParserCache()->getCacheStorage();
98 $success = $pc->deleteObjectsExpiringBefore(
100 [ $this,
'showProgressAndWait' ],
103 $this->getOption(
'tag',
null )
106 $this->fatalError(
"\nCannot purge this kind of parser cache." );
109 $this->output(
"\nDone\n" );
122 usleep( $this->usleep );
125 $percentString = sprintf(
"%.1f", $percent );
126 if ( $percentString === $this->lastProgress ) {
134 $now = microtime(
true );
135 $sec = sprintf(
"%.1f", $now - $this->lastTimestamp );
139 $this->output(
"... {$percentString}% done (+{$this->tmpCount} iterations in {$sec}s)\n" );
141 $this->lastProgress = $percentString;
143 $this->lastTimestamp = $now;