17 if ( $this->
getCliArg(
'use-bagostuff' ) ) {
39 $this->assertStringMatchesFormat(
40 '%Sfirst%Ssecond%Sthird%S',
42 'Local key interpolates parameters'
45 $this->assertStringMatchesFormat(
46 'global%Sfirst%Ssecond%Sthird%S',
48 'Global key interpolates parameters and contains global prefix'
51 $this->assertNotEquals(
54 'Local key and global key with same parameters should not be equal'
57 $this->assertNotEquals(
85 if ( $existingValue ===
false ) {
89 return $existingValue .
'merged';
93 $merged = $this->
cache->merge( $key, $callback, 0 );
94 $this->assertTrue( $merged );
95 $this->assertEquals( $this->
cache->get( $key ),
'merged' );
98 $merged = $this->
cache->merge( $key, $callback, 0 );
99 $this->assertTrue( $merged );
100 $this->assertEquals( $this->
cache->get( $key ),
'mergedmerged' );
108 $fork = (bool)$this->
getCliArg(
'use-bagostuff' );
109 $fork &= function_exists(
'pcntl_fork' );
123 $merged = $this->
cache->merge( $key, $callback, 0, 1 );
126 $this->assertFalse( $merged );
130 $this->assertEquals( $this->
cache->get( $key ),
'mergedmergedmerged' );
132 $this->
cache->merge( $key, $callback, 0, 1 );
152 $this->assertTrue( $this->
cache->changeTTL( $key, 5 ) );
153 $this->assertEquals( $this->
cache->get( $key ),
$value );
154 $this->
cache->delete( $key );
155 $this->assertFalse( $this->
cache->changeTTL( $key, 5 ) );
163 $this->assertTrue( $this->
cache->add( $key,
'test' ) );
167 $value = [
'this' =>
'is',
'a' =>
'test' ];
171 $this->assertEquals( $this->
cache->get( $key ),
$value );
183 return 'hello kitty';
187 $this->assertEquals(
'hello kitty',
$value );
188 $this->assertEquals(
$value, $this->
cache->get( $key ) );
196 $this->
cache->add( $key, 0 );
197 $this->
cache->incr( $key );
199 $actualValue = $this->
cache->get( $key );
200 $this->assertEquals( $expectedValue, $actualValue,
'Value should be 1 after incrementing' );
208 $val = $this->
cache->incrWithInit( $key, 0, 1, 3 );
209 $this->assertEquals( 3, $val,
"Correct init value" );
211 $val = $this->
cache->incrWithInit( $key, 0, 1, 3 );
212 $this->assertEquals( 4, $val,
"Correct init value" );
219 $value1 = [
'this' =>
'is',
'a' =>
'test' ];
220 $value2 = [
'this' =>
'is',
'another' =>
'test' ];
221 $value3 = [
'testing a key that may be encoded when sent to cache backend' ];
222 $value4 = [
'another test where chars in key will be encoded' ];
229 'flowdb:flow_ref:wiki:by-source:v3:Parser\'s_"broken"_+_(page)_&_grill:testwiki:1:4.7'
232 $this->
cache->add( $key1, $value1 );
233 $this->
cache->add( $key2, $value2 );
234 $this->
cache->add( $key3, $value3 );
235 $this->
cache->add( $key4, $value4 );
238 [ $key1 => $value1, $key2 => $value2, $key3 => $value3, $key4 => $value4 ],
239 $this->
cache->getMulti( [ $key1, $key2, $key3, $key4 ] )
243 $this->
cache->delete( $key1 );
244 $this->
cache->delete( $key2 );
245 $this->
cache->delete( $key3 );
246 $this->
cache->delete( $key4 );
254 $value1 = $this->
cache->getScopedLock( $key, 0 );
255 $value2 = $this->
cache->getScopedLock( $key, 0 );
258 $this->assertNull( $value2,
'Duplicate call returned no lock' );
262 $value3 = $this->
cache->getScopedLock( $key, 0 );
266 $value1 = $this->
cache->getScopedLock( $key, 0, 5,
'reentry' );
267 $value2 = $this->
cache->getScopedLock( $key, 0, 5,
'reentry' );
278 $logger = $this->getMock(
'Psr\Log\NullLogger' );
279 $logger->expects( $this->once() )
280 ->method(
'warning' )
281 ->with(
'Duplicate get(): "{key}" fetched {count} times', [
287 'reportDupes' =>
true,
288 'asyncHandler' =>
'DeferredUpdates::addCallableUpdate',
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static doUpdates($mode= 'run', $stage=self::ALL)
Do any deferred updates and clear the list.
testReportDupes()
BagOStuff::__construct BagOStuff::trackDuplicateKeys.
testIncrWithInit()
BagOStuff::incrWithInit.
testGetMulti()
BagOStuff::getMulti.
you have access to all of the normal MediaWiki so you can get a DB use the cache
testIncr()
BagOStuff::incr.
testGetWithSetCallback()
BagOStuff::getWithSetCallback.
testMerge()
BagOStuff::merge BagOStuff::mergeViaLock.
A cache class that replicates all writes to multiple child caches.
testGetScopedLock()
BagOStuff::getScopedLock.
A BagOStuff object with no objects in it.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
makeKey()
Make a cache key, scoped to this instance's keyspace.
get($key, $flags=0, $oldFlags=null)
Get an item with the given key.
wfMemcKey()
Make a cache key for the local wiki.
static newFromId($id)
Create a new cache object of the specified type.
testMakeKey()
BagOStuff::makeGlobalKey BagOStuff::makeKeyInternal.
makeKeyInternal($keyspace, $args)
Construct a cache key.
makeGlobalKey()
Make a global cache key.
testChangeTTL()
BagOStuff::changeTTL.
Allows to change the fields on the form that will be generated $name