108 final public function invoke( $n = 100 ) {
109 $posKey = $this->store->makeGlobalKey(
'WANCache',
'reaper', $this->channel );
110 $scopeLock = $this->store->getScopedLock(
"$posKey:busy", 0 );
116 $status = $this->store->get( $posKey );
122 $events = call_user_func_array(
123 $this->logChunkCallback,
124 [ $status[
'pos'], $status[
'id'], $now - WANObjectCache::HOLDOFF_TTL - 1, $n ]
129 foreach ( $events as $event ) {
130 $keys = call_user_func_array(
131 $this->keyListCallback,
132 [ $this->cache, $event[
'item'] ]
134 foreach (
$keys as $key ) {
136 unset( $keyEvents[$key] );
138 'pos' => $event[
'pos'],
146 foreach ( $keyEvents as $key => $keyEvent ) {
147 if ( !$this->cache->reap( $key, $keyEvent[
'pos'] ) ) {
151 $lastOkEvent = $event;
154 if ( $lastOkEvent ) {
155 $ok = $this->store->merge(
157 static function ( $bag, $key, $curValue ) use ( $lastOkEvent ) {
161 $curCoord = [ $curValue[
'pos'], $curValue[
'id'] ];
162 $newCoord = [ $lastOkEvent[
'pos'], $lastOkEvent[
'id'] ];
163 if ( $newCoord < $curCoord ) {
170 'pos' => $lastOkEvent[
'pos'],
171 'id' => $lastOkEvent[
'id'],
172 'ctime' => $curValue ? $curValue[
'ctime'] : date(
'c' )
175 BagOStuff::TTL_INDEFINITE
178 $pos = $lastOkEvent[
'pos'];
179 $id = $lastOkEvent[
'id'];
181 $this->logger->info(
"Updated cache reap position ($pos, $id)." );
183 $this->logger->error(
"Could not update cache reap position ($pos, $id)." );
187 ScopedCallback::consume( $scopeLock );