MediaWiki master
BlobStoreFactory.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Storage;
8
14
23
27 private $lbFactory;
28
32 private $extStoreAccess;
33
37 private $cache;
38
42 private $options;
43
47 public const CONSTRUCTOR_OPTIONS = [
52 ];
53
54 public function __construct(
55 ILBFactory $lbFactory,
56 ExternalStoreAccess $extStoreAccess,
57 WANObjectCache $cache,
58 ServiceOptions $options
59 ) {
60 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
61
62 $this->lbFactory = $lbFactory;
63 $this->extStoreAccess = $extStoreAccess;
64 $this->cache = $cache;
65 $this->options = $options;
66 }
67
75 public function newBlobStore( $dbDomain = false ) {
76 return $this->newSqlBlobStore( $dbDomain );
77 }
78
86 public function newSqlBlobStore( $dbDomain = false ) {
87 $lb = $this->lbFactory->getMainLB( $dbDomain );
88 $store = new SqlBlobStore(
89 $lb,
90 $this->extStoreAccess,
91 $this->cache,
92 $dbDomain
93 );
94
95 $store->setCompressBlobs( $this->options->get( MainConfigNames::CompressRevisions ) );
96 $store->setCacheExpiry( $this->options->get( MainConfigNames::RevisionCacheExpiry ) );
97 $store->setUseExternalStore(
98 $this->options->get( MainConfigNames::DefaultExternalStore ) !== false );
99
100 if ( $this->options->get( MainConfigNames::LegacyEncoding ) ) {
101 $store->setLegacyEncoding( $this->options->get( MainConfigNames::LegacyEncoding ) );
102 }
103
104 return $store;
105 }
106
107}
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
This is the main interface for fetching or inserting objects with ExternalStore.
A class containing constants representing the names of configuration variables.
const RevisionCacheExpiry
Name constant for the RevisionCacheExpiry setting, for use with Config::get()
const LegacyEncoding
Name constant for the LegacyEncoding setting, for use with Config::get()
const DefaultExternalStore
Name constant for the DefaultExternalStore setting, for use with Config::get()
const CompressRevisions
Name constant for the CompressRevisions setting, for use with Config::get()
Service for instantiating BlobStores.
__construct(ILBFactory $lbFactory, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, ServiceOptions $options)
Service for storing and loading Content objects representing revision data blobs.
Multi-datacenter aware caching interface.
Manager of ILoadBalancer objects and, indirectly, IDatabase connections.