3use Wikimedia\TestingAccessWrapper;
10 use MediaWikiCoversValidator;
16 $this->assertInstanceOf(
51 for ( $i = 0; $i < 10; $i++ ) {
53 $this->assertEquals( 1,
$cache->get(
"key$i" ) );
55 $this->assertEquals(
false,
$cache->get(
"key$i" ) );
64 for ( $i = 0; $i < 10; $i++ ) {
66 $this->assertEquals( 1,
$cache->get(
"key$i" ) );
69 for ( $i = 0; $i < 10; $i++ ) {
70 $this->assertEquals(
false,
$cache->get(
"key$i" ) );
80 $cacheInternal = TestingAccessWrapper::newFromObject(
$cache );
82 $cache->set(
'bar', 1, 10 );
83 $cache->set(
'baz', 1, -10 );
85 $this->assertEquals( 0, $cacheInternal->bag[
'foo'][$cache::KEY_EXP],
'Indefinite' );
87 $this->assertEquals( time() + 10, $cacheInternal->bag[
'bar'][$cache::KEY_EXP],
'Future', 2 );
88 $this->assertEquals( time() - 10, $cacheInternal->bag[
'baz'][$cache::KEY_EXP],
'Past', 2 );
90 $this->assertEquals( 1,
$cache->get(
'bar' ),
'Key not expired' );
91 $this->assertEquals(
false,
$cache->get(
'baz' ),
'Key expired' );
101 for ( $i = 0; $i < 10; $i++ ) {
102 $cache->set(
"key$i", 1 );
103 $this->assertEquals( 1,
$cache->get(
"key$i" ) );
105 for ( $i = 10; $i < 20; $i++ ) {
106 $cache->set(
"key$i", 1 );
107 $this->assertEquals( 1,
$cache->get(
"key$i" ) );
108 $this->assertEquals(
false,
$cache->get(
"key" . ( $i - 10 ) ) );
121 foreach ( [
'foo',
'bar',
'baz' ] as $key ) {
132 foreach ( [
'foo',
'baz',
'quux' ] as $key ) {
133 $this->assertEquals( 1,
$cache->get( $key ),
"Kept $key" );
135 $this->assertEquals(
false,
$cache->get(
'bar' ),
'Evicted bar' );
147 foreach ( [
'foo',
'bar',
'baz' ] as $key ) {
158 foreach ( [
'foo',
'baz',
'quux' ] as $key ) {
159 $this->assertEquals( 1,
$cache->get( $key ),
"Kept $key" );
161 $this->assertEquals(
false,
$cache->get(
'bar' ),
'Evicted bar' );
testConstructBadType()
HashBagOStuff::__construct InvalidArgumentException.
testConstructBadZero()
HashBagOStuff::__construct InvalidArgumentException.
testEvictionGet()
Ensure maxKeys eviction prefers recently retrieved keys (LRU).
testEvictionAdd()
Ensure maxKeys eviction prefers keeping new keys.
testConstruct()
HashBagOStuff::__construct.
testDelete()
HashBagOStuff::delete.
testExpire()
HashBagOStuff::doGet HashBagOStuff::expire.
testEvictionSet()
Ensure maxKeys eviction prefers recently set keys even if the keys pre-exist.
testClear()
HashBagOStuff::clear.
testConstructBadNeg()
HashBagOStuff::__construct InvalidArgumentException.
Simple store for keeping values in an associative array for the current process.