MediaWiki  1.30.0
MediaWiki\Services\SalvageableService Interface Reference

SalvageableService defines an interface for services that are able to salvage state from a previous instance of the same class. More...

Inheritance diagram for MediaWiki\Services\SalvageableService:

Public Member Functions

 salvage (SalvageableService $other)
 Re-uses state from $other. More...
 

Detailed Description

SalvageableService defines an interface for services that are able to salvage state from a previous instance of the same class.

The intent is to allow new service instances to re-use resources that would be expensive to re-create, such as cached data or network connections.

Note
There is no expectation that services will be destroyed when the process (or web request) terminates.

Definition at line 35 of file SalvageableService.php.

Member Function Documentation

◆ salvage()

MediaWiki\Services\SalvageableService::salvage ( SalvageableService  $other)

Re-uses state from $other.

$other must not be used after being passed to salvage(), and should be considered to be destroyed.

Note
Implementations are responsible for determining what parts of $other can be re-used safely. In particular, implementations should check that the relevant configuration of $other is the same as in $this before re-using resources from $other.
Implementations must take care to detach any re-used resources from the original service instance. If $other is destroyed later, resources that are now used by the new service instance must not be affected.
If $other is a DestructibleService, implementations should make sure that $other is in destroyed state after salvage finished. This may be done by calling $other->destroy() after carefully detaching all relevant resources.
Parameters
SalvageableService$otherThe object to salvage state from. $other must have the exact same type as $this.

Implemented in ConfigFactory.


The documentation for this interface was generated from the following file: