79 public function error( $status ) {
89 return $this->poolCounter->isFastStaleEnabled();
99 $key = $this->poolCounter->getKey();
101 wfDebugLog(
'poolcounter',
"Pool key '$key' ({$this->type}): "
102 . $status->getMessage()->inLanguage(
'en' )->useDatabase(
false )->text() );
127 public function execute( $skipcache =
false ) {
128 if ( $this->cacheable && !$skipcache ) {
132 $status = $this->poolCounter->acquireForAnyone( 0 );
135 $staleResult = $this->
fallback(
true );
136 if ( $staleResult !==
false ) {
140 $status = $this->poolCounter->acquireForAnyone();
143 $status = $this->poolCounter->acquireForAnyone();
146 $status = $this->poolCounter->acquireForMe();
149 if ( !$status->isOK() ) {
155 switch ( $status->value ) {
162 $result = $this->
doWork();
164 $this->poolCounter->release();
170 if ( $result ===
false ) {
182 if ( $result !==
false ) {
194 $status = Status::newFatal( $errors[$status->value] ??
'pool-errorunknown' );
196 return $this->
error( $status );
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Class for dealing with PoolCounters using class members.
error( $status)
Do something with the error, like showing it to the user.
getCachedWork()
Retrieve the work from cache.
fallback( $fast)
A work not so good (eg.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
isFastStaleEnabled()
Should fast stale mode be used?
doWork()
Actually perform the work, caching it if needed.
__construct(string $type, string $key, PoolCounter $poolCounter=null)
logError( $status)
Log an error.
When you have many workers (threads/servers) giving service, and a cached item expensive to produce e...
static factory(string $type, string $key)
Create a Pool counter.