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