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 
61  public const CONSTRUCTOR_OPTIONS = [
62  'CompressRevisions',
63  'DefaultExternalStore',
64  'LegacyEncoding',
65  'RevisionCacheExpiry',
66  ];
67 
68  public function __construct(
73  ) {
74  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
75 
76  $this->lbFactory = $lbFactory;
77  $this->extStoreAccess = $extStoreAccess;
78  $this->cache = $cache;
79  $this->options = $options;
80  }
81 
89  public function newBlobStore( $dbDomain = false ) {
90  return $this->newSqlBlobStore( $dbDomain );
91  }
92 
100  public function newSqlBlobStore( $dbDomain = false ) {
101  $lb = $this->lbFactory->getMainLB( $dbDomain );
102  $store = new SqlBlobStore(
103  $lb,
104  $this->extStoreAccess,
105  $this->cache,
106  $dbDomain
107  );
108 
109  $store->setCompressBlobs( $this->options->get( 'CompressRevisions' ) );
110  $store->setCacheExpiry( $this->options->get( 'RevisionCacheExpiry' ) );
111  $store->setUseExternalStore( $this->options->get( 'DefaultExternalStore' ) !== false );
112 
113  if ( $this->options->get( 'LegacyEncoding' ) ) {
114  $store->setLegacyEncoding( $this->options->get( 'LegacyEncoding' ) );
115  }
116 
117  return $store;
118  }
119 
120 }
MediaWiki\Storage\BlobStoreFactory\newBlobStore
newBlobStore( $dbDomain=false)
Definition: BlobStoreFactory.php:89
MediaWiki\Storage\BlobStoreFactory\__construct
__construct(ILBFactory $lbFactory, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, ServiceOptions $options)
Definition: BlobStoreFactory.php:68
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
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:100
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