| @@ 112-136 (lines=25) @@ | ||
| 109 | * @see JobQueue::doGetAcquiredCount() |
|
| 110 | * @return int |
|
| 111 | */ |
|
| 112 | protected function doGetAcquiredCount() { |
|
| 113 | if ( $this->claimTTL <= 0 ) { |
|
| 114 | return 0; // no acknowledgements |
|
| 115 | } |
|
| 116 | ||
| 117 | $key = $this->getCacheKey( 'acquiredcount' ); |
|
| 118 | ||
| 119 | $count = $this->cache->get( $key ); |
|
| 120 | if ( is_int( $count ) ) { |
|
| 121 | return $count; |
|
| 122 | } |
|
| 123 | ||
| 124 | $dbr = $this->getSlaveDB(); |
|
| 125 | try { |
|
| 126 | $count = (int)$dbr->selectField( 'job', 'COUNT(*)', |
|
| 127 | [ 'job_cmd' => $this->type, "job_token != {$dbr->addQuotes( '' )}" ], |
|
| 128 | __METHOD__ |
|
| 129 | ); |
|
| 130 | } catch ( DBError $e ) { |
|
| 131 | $this->throwDBException( $e ); |
|
| 132 | } |
|
| 133 | $this->cache->set( $key, $count, self::CACHE_TTL_SHORT ); |
|
| 134 | ||
| 135 | return $count; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @see JobQueue::doGetAbandonedCount() |
|
| @@ 143-172 (lines=30) @@ | ||
| 140 | * @return int |
|
| 141 | * @throws MWException |
|
| 142 | */ |
|
| 143 | protected function doGetAbandonedCount() { |
|
| 144 | if ( $this->claimTTL <= 0 ) { |
|
| 145 | return 0; // no acknowledgements |
|
| 146 | } |
|
| 147 | ||
| 148 | $key = $this->getCacheKey( 'abandonedcount' ); |
|
| 149 | ||
| 150 | $count = $this->cache->get( $key ); |
|
| 151 | if ( is_int( $count ) ) { |
|
| 152 | return $count; |
|
| 153 | } |
|
| 154 | ||
| 155 | $dbr = $this->getSlaveDB(); |
|
| 156 | try { |
|
| 157 | $count = (int)$dbr->selectField( 'job', 'COUNT(*)', |
|
| 158 | [ |
|
| 159 | 'job_cmd' => $this->type, |
|
| 160 | "job_token != {$dbr->addQuotes( '' )}", |
|
| 161 | "job_attempts >= " . $dbr->addQuotes( $this->maxTries ) |
|
| 162 | ], |
|
| 163 | __METHOD__ |
|
| 164 | ); |
|
| 165 | } catch ( DBError $e ) { |
|
| 166 | $this->throwDBException( $e ); |
|
| 167 | } |
|
| 168 | ||
| 169 | $this->cache->set( $key, $count, self::CACHE_TTL_SHORT ); |
|
| 170 | ||
| 171 | return $count; |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * @see JobQueue::doBatchPush() |
|