MediaWiki  master
BlobStoreFactory.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Storage;
22 
25 use WANObjectCache;
27 
36 
40  private $lbFactory;
41 
45  private $extStoreAccess;
46 
50  private $cache;
51 
55  private $options;
56 
60  public const CONSTRUCTOR_OPTIONS = [
61  'CompressRevisions',
62  'DefaultExternalStore',
63  'LegacyEncoding',
64  'RevisionCacheExpiry',
65  ];
66 
67  public function __construct(
72  ) {
73  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
74 
75  $this->lbFactory = $lbFactory;
76  $this->extStoreAccess = $extStoreAccess;
77  $this->cache = $cache;
78  $this->options = $options;
79  }
80 
88  public function newBlobStore( $dbDomain = false ) {
89  return $this->newSqlBlobStore( $dbDomain );
90  }
91 
99  public function newSqlBlobStore( $dbDomain = false ) {
100  $lb = $this->lbFactory->getMainLB( $dbDomain );
101  $store = new SqlBlobStore(
102  $lb,
103  $this->extStoreAccess,
104  $this->cache,
105  $dbDomain
106  );
107 
108  $store->setCompressBlobs( $this->options->get( 'CompressRevisions' ) );
109  $store->setCacheExpiry( $this->options->get( 'RevisionCacheExpiry' ) );
110  $store->setUseExternalStore( $this->options->get( 'DefaultExternalStore' ) !== false );
111 
112  if ( $this->options->get( 'LegacyEncoding' ) ) {
113  $store->setLegacyEncoding( $this->options->get( 'LegacyEncoding' ) );
114  }
115 
116  return $store;
117  }
118 
119 }
MediaWiki\Storage\BlobStoreFactory\newBlobStore
newBlobStore( $dbDomain=false)
Definition: BlobStoreFactory.php:88
MediaWiki\Storage\BlobStoreFactory\__construct
__construct(ILBFactory $lbFactory, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, ServiceOptions $options)
Definition: BlobStoreFactory.php:67
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
MediaWiki\Storage\BlobStoreFactory\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: BlobStoreFactory.php:60
MediaWiki\Storage\BlobStoreFactory\$lbFactory
ILBFactory $lbFactory
Definition: BlobStoreFactory.php:40
ExternalStoreAccess
Key/value blob storage for a collection of storage medium types (e.g.
Definition: ExternalStoreAccess.php:22
MediaWiki\Storage\BlobStoreFactory\newSqlBlobStore
newSqlBlobStore( $dbDomain=false)
Definition: BlobStoreFactory.php:99
MediaWiki\Storage\BlobStoreFactory\$cache
WANObjectCache $cache
Definition: BlobStoreFactory.php:50
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:25
MediaWiki\Storage\BlobStoreFactory
Service for instantiating BlobStores.
Definition: BlobStoreFactory.php:35
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:125
MediaWiki\Storage\BlobStoreFactory\$extStoreAccess
ExternalStoreAccess $extStoreAccess
Definition: BlobStoreFactory.php:45
MediaWiki\Storage\BlobStoreFactory\$options
ServiceOptions $options
Definition: BlobStoreFactory.php:55
MediaWiki\Storage
Definition: BlobAccessException.php:23
MediaWiki\Config\ServiceOptions\assertRequiredOptions
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Definition: ServiceOptions.php:62
Wikimedia\Rdbms\ILBFactory
An interface for generating database load balancers.
Definition: ILBFactory.php:33