3 use Wikimedia\TestingAccessWrapper;
16 'pool' =>
'testcache-hash',
20 $wanCache = TestingAccessWrapper::newFromObject( $this->
cache );
22 $this->internalCache = $wanCache->cache;
38 $this->
cache->get( $key, $curTTL, [], $asOf );
39 $this->assertNull( $curTTL,
"Current TTL is null" );
40 $this->assertNull( $asOf,
"Current as-of-time is infinite" );
42 $t = microtime(
true );
45 $this->assertEquals(
$value, $this->
cache->get( $key, $curTTL, [], $asOf ) );
46 if ( is_infinite( $ttl ) || $ttl == 0 ) {
47 $this->assertTrue( is_infinite( $curTTL ),
"Current TTL is infinite" );
49 $this->assertGreaterThan( 0, $curTTL,
"Current TTL > 0" );
50 $this->assertLessThanOrEqual( $ttl, $curTTL,
"Current TTL < nominal TTL" );
52 $this->assertGreaterThanOrEqual(
$t - 1, $asOf,
"As-of-time in range of set() time" );
53 $this->assertLessThanOrEqual(
$t + 1, $asOf,
"As-of-time in range of set() time" );
79 $this->assertFalse(
$value,
"Non-existing key has false value" );
80 $this->assertNull( $curTTL,
"Non-existing key has null current TTL" );
88 for ( $i = 0; $i < 3; ++$i ) {
92 $this->assertEquals( $this->
cache->get( $key ),
$value );
102 $this->
cache->set( $key,
$value, 3, [
'since' => microtime(
true ) - 30 ] );
104 $this->assertFalse( $this->
cache->get( $key ),
"Stale set() value ignored" );
109 $callback =
function ()
use ( &$hit ) {
114 $groups = [
'thiscache:1',
'thatcache:1',
'somecache:1' ];
116 foreach (
$keys as $i => $key ) {
117 $this->
cache->getWithSetCallback(
118 $key, 100, $callback, [
'pcTTL' => 5,
'pcGroup' => $groups[$i] ] );
120 $this->assertEquals( 3, $hit );
122 foreach (
$keys as $i => $key ) {
123 $this->
cache->getWithSetCallback(
124 $key, 100, $callback, [
'pcTTL' => 5,
'pcGroup' => $groups[$i] ] );
126 $this->assertEquals( 3, $hit,
"Values cached" );
128 foreach (
$keys as $i => $key ) {
129 $this->
cache->getWithSetCallback(
130 "$key-2", 100, $callback, [
'pcTTL' => 5,
'pcGroup' => $groups[$i] ] );
132 $this->assertEquals( 6, $hit );
134 foreach (
$keys as $i => $key ) {
135 $this->
cache->getWithSetCallback(
136 "$key-2", 100, $callback, [
'pcTTL' => 5,
'pcGroup' => $groups[$i] ] );
138 $this->assertEquals( 6, $hit,
"New values cached" );
140 foreach (
$keys as $i => $key ) {
141 $this->
cache->delete( $key );
142 $this->
cache->getWithSetCallback(
143 $key, 100, $callback, [
'pcTTL' => 5,
'pcGroup' => $groups[$i] ] );
145 $this->assertEquals( 9, $hit,
"Values evicted" );
147 $key = reset(
$keys );
149 $this->
cache->getWithSetCallback( $key, 100, $callback, [
'pcTTL' => 5 ] );
150 $this->
cache->getWithSetCallback( $key, 100, $callback, [
'pcTTL' => 5 ] );
151 $this->assertEquals( 10, $hit,
"Value cached" );
152 $outerCallback =
function ()
use ( &$callback, $key ) {
153 $v = $this->
cache->getWithSetCallback( $key, 100, $callback, [
'pcTTL' => 5 ] );
157 $this->
cache->getWithSetCallback( $key, 100, $outerCallback );
158 $this->assertEquals( 11, $hit,
"Nested callback value process cache skipped" );
179 $func =
function( $old, &$ttl, &$opts, $asOf )
180 use ( &$wasSet, &$priorValue, &$priorAsOf,
$value )
191 $this->assertEquals(
$value, $v,
"Value returned" );
192 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
193 $this->assertFalse( $priorValue,
"No prior value" );
194 $this->assertNull( $priorAsOf,
"No prior value" );
198 $this->assertLessThanOrEqual( 20, $curTTL,
'Current TTL between 19-20 (overriden)' );
199 $this->assertGreaterThanOrEqual( 19, $curTTL,
'Current TTL between 19-20 (overriden)' );
206 $this->assertEquals(
$value, $v,
"Value returned" );
207 $this->assertEquals( 0, $wasSet,
"Value not regenerated" );
209 $priorTime = microtime(
true );
213 $key, 30, $func, [
'checkKeys' => [ $cKey1, $cKey2 ] ] + $extOpts
215 $this->assertEquals(
$value, $v,
"Value returned" );
216 $this->assertEquals( 1, $wasSet,
"Value regenerated due to check keys" );
217 $this->assertEquals(
$value, $priorValue,
"Has prior value" );
218 $this->assertInternalType(
'float', $priorAsOf,
"Has prior value" );
220 $this->assertGreaterThanOrEqual( $priorTime, $t1,
'Check keys generated on miss' );
222 $this->assertGreaterThanOrEqual( $priorTime, $t2,
'Check keys generated on miss' );
224 $priorTime = microtime(
true );
227 $key, 30, $func, [
'checkKeys' => [ $cKey1, $cKey2 ] ] + $extOpts
229 $this->assertEquals(
$value, $v,
"Value returned" );
230 $this->assertEquals( 1, $wasSet,
"Value regenerated due to still-recent check keys" );
232 $this->assertLessThanOrEqual( $priorTime, $t1,
'Check keys did not change again' );
234 $this->assertLessThanOrEqual( $priorTime, $t2,
'Check keys did not change again' );
237 $v =
$cache->
get( $key, $curTTL, [ $cKey1, $cKey2 ] );
239 $this->assertEquals(
$value, $v[$cache::VFLD_DATA],
"Value returned" );
241 $this->assertEquals(
$value, $v,
"Value returned" );
243 $this->assertLessThanOrEqual( 0, $curTTL,
"Value has current TTL < 0 due to check keys" );
248 $this->assertEquals(
$value, $v,
"Value returned" );
251 $this->assertEquals(
$value, $v,
"Value still returned after deleted" );
252 $this->assertEquals( 1, $wasSet,
"Value process cached while deleted" );
258 [ [
'version' => 1 ],
true ]
281 $genFunc =
function ( $id, $old, &$ttl, &$opts, $asOf )
use (
282 &$wasSet, &$priorValue, &$priorAsOf
292 $keyedIds =
new ArrayIterator( [ $keyA => 3353 ] );
295 $keyedIds, 30, $genFunc, [
'lockTSE' => 5 ] + $extOpts );
296 $this->assertEquals(
$value, $v[$keyA],
"Value returned" );
297 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
298 $this->assertFalse( $priorValue,
"No prior value" );
299 $this->assertNull( $priorAsOf,
"No prior value" );
303 $this->assertLessThanOrEqual( 20, $curTTL,
'Current TTL between 19-20 (overriden)' );
304 $this->assertGreaterThanOrEqual( 19, $curTTL,
'Current TTL between 19-20 (overriden)' );
308 $keyedIds =
new ArrayIterator( [ $keyB =>
'efef' ] );
310 $keyedIds, 30, $genFunc, [
'lowTTL' => 0,
'lockTSE' => 5, ] + $extOpts );
311 $this->assertEquals(
$value, $v[$keyB],
"Value returned" );
312 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
314 $keyedIds, 30, $genFunc, [
'lowTTL' => 0,
'lockTSE' => 5, ] + $extOpts );
315 $this->assertEquals(
$value, $v[$keyB],
"Value returned" );
316 $this->assertEquals( 1, $wasSet,
"Value not regenerated" );
318 $priorTime = microtime(
true );
321 $keyedIds =
new ArrayIterator( [ $keyB =>
'efef' ] );
323 $keyedIds, 30, $genFunc, [
'checkKeys' => [ $cKey1, $cKey2 ] ] + $extOpts
325 $this->assertEquals(
$value, $v[$keyB],
"Value returned" );
326 $this->assertEquals( 1, $wasSet,
"Value regenerated due to check keys" );
327 $this->assertEquals(
$value, $priorValue,
"Has prior value" );
328 $this->assertInternalType(
'float', $priorAsOf,
"Has prior value" );
330 $this->assertGreaterThanOrEqual( $priorTime, $t1,
'Check keys generated on miss' );
332 $this->assertGreaterThanOrEqual( $priorTime, $t2,
'Check keys generated on miss' );
334 $priorTime = microtime(
true );
337 $keyedIds =
new ArrayIterator( [ $keyC => 43636 ] );
339 $keyedIds, 30, $genFunc, [
'checkKeys' => [ $cKey1, $cKey2 ] ] + $extOpts
341 $this->assertEquals(
$value, $v[$keyC],
"Value returned" );
342 $this->assertEquals( 1, $wasSet,
"Value regenerated due to still-recent check keys" );
344 $this->assertLessThanOrEqual( $priorTime, $t1,
'Check keys did not change again' );
346 $this->assertLessThanOrEqual( $priorTime, $t2,
'Check keys did not change again' );
349 $v =
$cache->
get( $keyC, $curTTL, [ $cKey1, $cKey2 ] );
351 $this->assertEquals(
$value, $v[$cache::VFLD_DATA],
"Value returned" );
353 $this->assertEquals(
$value, $v,
"Value returned" );
355 $this->assertLessThanOrEqual( 0, $curTTL,
"Value has current TTL < 0 due to check keys" );
359 $keyedIds =
new ArrayIterator( [ $key => 242424 ] );
361 $keyedIds, 30, $genFunc, [
'pcTTL' => 5 ] + $extOpts );
362 $this->assertEquals(
"@{$keyedIds[$key]}$", $v[$key],
"Value returned" );
364 $keyedIds =
new ArrayIterator( [ $key => 242424 ] );
366 $keyedIds, 30, $genFunc, [
'pcTTL' => 5 ] + $extOpts );
367 $this->assertEquals(
"@{$keyedIds[$key]}$", $v[$key],
"Value still returned after deleted" );
368 $this->assertEquals( 1, $wasSet,
"Value process cached while deleted" );
371 $ids = [ 1, 2, 3, 4, 5, 6 ];
373 return $wanCache->makeKey(
'test', $id );
376 $genFunc =
function ( $id, $oldValue, &$ttl,
array &$setops )
use ( &$calls ) {
384 [
"val-1",
"val-2",
"val-3",
"val-4",
"val-5",
"val-6" ],
385 array_values( $values ),
386 "Correct values in correct order"
389 array_map( $keyFunc, $ids, array_fill( 0,
count( $ids ), $this->
cache ) ),
390 array_keys( $values ),
391 "Correct keys in correct order"
393 $this->assertEquals(
count( $ids ), $calls );
396 $this->assertEquals(
count( $ids ), $calls,
"Values cached" );
402 [ [
'version' => 1 ],
true ]
425 $this->assertEquals( 1, $calls,
'Value was populated' );
428 $this->internalCache->add( $cache::MUTEX_KEY_PREFIX . $key, 1, 0 );
432 [
'lockTSE' => 5,
'checkKeys' => $checkKeys ] );
433 $this->assertEquals(
$value,
$ret,
'Old value used' );
434 $this->assertEquals( 1, $calls,
'Callback was not used' );
438 [
'lockTSE' => 5,
'checkKeys' => $checkKeys ] );
439 $this->assertEquals(
$value,
$ret,
'Callback was used; interim saved' );
440 $this->assertEquals( 2, $calls,
'Callback was used; interim saved' );
443 [
'lockTSE' => 5,
'checkKeys' => $checkKeys ] );
444 $this->assertEquals(
$value,
$ret,
'Callback was not used; used interim' );
445 $this->assertEquals( 2, $calls,
'Callback was not used; used interim' );
458 $func =
function( $oldValue, &$ttl, &$setOpts )
use ( &$calls,
$value,
$cache, $key ) {
460 $setOpts[
'since'] = microtime(
true ) - 10;
470 $this->assertEquals(
$value,
$cache->
get( $key, $curTTL ),
'Value was populated' );
471 $this->assertLessThan( 0, $curTTL,
'Value has negative curTTL' );
472 $this->assertEquals( 1, $calls,
'Value was generated' );
475 $this->internalCache->add( $cache::MUTEX_KEY_PREFIX . $key, 1, 0 );
478 $this->assertEquals( 1, $calls,
'Callback was not used' );
501 $this->assertEquals( 1, $calls,
'Value was populated' );
504 $this->internalCache->add( $cache::MUTEX_KEY_PREFIX . $key, 1, 0 );
508 [
'busyValue' => $busyValue,
'checkKeys' => $checkKeys ] );
509 $this->assertEquals(
$value,
$ret,
'Callback used' );
510 $this->assertEquals( 2, $calls,
'Callback used' );
513 [
'lockTSE' => 30,
'busyValue' => $busyValue,
'checkKeys' => $checkKeys ] );
514 $this->assertEquals(
$value,
$ret,
'Old value used' );
515 $this->assertEquals( 2, $calls,
'Callback was not used' );
519 [
'busyValue' => $busyValue,
'checkKeys' => $checkKeys ] );
520 $this->assertEquals( $busyValue,
$ret,
'Callback was not used; used busy value' );
521 $this->assertEquals( 2, $calls,
'Callback was not used; used busy value' );
523 $this->internalCache->delete( $cache::MUTEX_KEY_PREFIX . $key );
525 [
'lockTSE' => 30,
'busyValue' => $busyValue,
'checkKeys' => $checkKeys ] );
526 $this->assertEquals(
$value,
$ret,
'Callback was used; saved interim' );
527 $this->assertEquals( 3, $calls,
'Callback was used; saved interim' );
529 $this->internalCache->add( $cache::MUTEX_KEY_PREFIX . $key, 1, 0 );
531 [
'busyValue' => $busyValue,
'checkKeys' => $checkKeys ] );
532 $this->assertEquals(
$value,
$ret,
'Callback was not used; used interim' );
533 $this->assertEquals( 3, $calls,
'Callback was not used; used interim' );
542 $value1 = [
'this' =>
'is',
'a' =>
'test' ];
543 $value2 = [
'this' =>
'is',
'another' =>
'test' ];
554 [ $key1 => $value1, $key2 => $value2 ],
556 'Result array populated'
559 $this->assertEquals( 2,
count( $curTTLs ),
"Two current TTLs in array" );
560 $this->assertGreaterThan( 0, $curTTLs[$key1],
"Key 1 has current TTL > 0" );
561 $this->assertGreaterThan( 0, $curTTLs[$key2],
"Key 2 has current TTL > 0" );
566 $priorTime = microtime(
true );
570 [ $key1 => $value1, $key2 => $value2 ],
571 $cache->
getMulti( [ $key1, $key2, $key3 ], $curTTLs, [ $cKey1, $cKey2 ] ),
572 "Result array populated even with new check keys"
575 $this->assertGreaterThanOrEqual( $priorTime, $t1,
'Check key 1 generated on miss' );
577 $this->assertGreaterThanOrEqual( $priorTime, $t2,
'Check key 2 generated on miss' );
578 $this->assertEquals( 2,
count( $curTTLs ),
"Current TTLs array set" );
579 $this->assertLessThanOrEqual( 0, $curTTLs[$key1],
'Key 1 has current TTL <= 0' );
580 $this->assertLessThanOrEqual( 0, $curTTLs[$key2],
'Key 2 has current TTL <= 0' );
585 [ $key1 => $value1, $key2 => $value2 ],
586 $cache->
getMulti( [ $key1, $key2, $key3 ], $curTTLs, [ $cKey1, $cKey2 ] ),
587 "Result array still populated even with new check keys"
589 $this->assertEquals( 2,
count( $curTTLs ),
"Current TTLs still array set" );
590 $this->assertLessThan( 0, $curTTLs[$key1],
'Key 1 has negative current TTL' );
591 $this->assertLessThan( 0, $curTTLs[$key2],
'Key 2 has negative current TTL' );
610 foreach ( [ $checkAll, $check1, $check2 ]
as $checkKey ) {
626 [
'key1' => $value1,
'key2' => $value2 ],
630 $this->assertGreaterThanOrEqual( 9.5, $curTTLs[
'key1'],
'Initial ttls' );
631 $this->assertLessThanOrEqual( 10.5, $curTTLs[
'key1'],
'Initial ttls' );
632 $this->assertGreaterThanOrEqual( 9.5, $curTTLs[
'key2'],
'Initial ttls' );
633 $this->assertLessThanOrEqual( 10.5, $curTTLs[
'key2'],
'Initial ttls' );
645 [
'key1' => $value1,
'key2' => $value2 ],
647 'key1 expired by check1, but value still provided'
649 $this->assertLessThan( 0, $curTTLs[
'key1'],
'key1 TTL expired' );
650 $this->assertGreaterThan( 0, $curTTLs[
'key2'],
'key2 still valid' );
662 [
'key1' => $value1,
'key2' => $value2 ],
664 'All keys expired by checkAll, but value still provided'
666 $this->assertLessThan( 0, $curTTLs[
'key1'],
'key1 expired by checkAll' );
667 $this->assertLessThan( 0, $curTTLs[
'key2'],
'key2 expired by checkAll' );
677 for ( $i = 0; $i < 500; ++$i ) {
681 $cache->
get( $key, $curTTL, [ $checkKey ] );
684 $v =
$cache->
get( $key, $curTTL, [ $checkKey ] );
686 $this->assertEquals(
'val', $v );
687 $this->assertLessThan( 0, $curTTL,
"Step $i: CTL < 0 (miss/set/hit)" );
690 for ( $i = 0; $i < 500; ++$i ) {
696 $v =
$cache->
get( $key, $curTTL, [ $checkKey ] );
698 $this->assertEquals(
'val', $v );
699 $this->assertLessThan( 0, $curTTL,
"Step $i: CTL < 0 (set/hit)" );
712 $v = $this->
cache->get( $key, $curTTL );
713 $this->assertEquals(
$value, $v,
"Key was created with value" );
714 $this->assertGreaterThan( 0, $curTTL,
"Existing key has current TTL > 0" );
716 $this->
cache->delete( $key );
719 $v = $this->
cache->get( $key, $curTTL );
720 $this->assertFalse( $v,
"Deleted key has false value" );
721 $this->assertLessThan( 0, $curTTL,
"Deleted key has current TTL < 0" );
724 $v = $this->
cache->get( $key, $curTTL );
725 $this->assertFalse( $v,
"Deleted key is tombstoned and has false value" );
726 $this->assertLessThan( 0, $curTTL,
"Deleted key is tombstoned and has current TTL < 0" );
732 $v = $this->
cache->get( $key, $curTTL );
733 $this->assertFalse( $v,
"Deleted key has false value" );
734 $this->assertNull( $curTTL,
"Deleted key has null current TTL" );
737 $v = $this->
cache->get( $key, $curTTL );
738 $this->assertEquals(
$value, $v,
"Key was created with value" );
739 $this->assertGreaterThan( 0, $curTTL,
"Existing key has current TTL > 0" );
754 $func =
function( $old, &$ttl )
use ( &$wasSet,
$value ) {
762 $this->assertEquals(
$value, $v,
"Value returned" );
763 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
765 $this->assertEquals( 1, $wasSet,
"Value not regenerated" );
768 $verOpts = [
'version' => $extOpts[
'version'] + 1 ];
772 $this->assertEquals(
$value, $v,
"Value returned" );
773 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
777 $this->assertEquals(
$value, $v,
"Value returned" );
778 $this->assertEquals( 0, $wasSet,
"Value not regenerated" );
783 $this->assertEquals( 0, $wasSet,
"Value not regenerated" );
788 $this->assertEquals(
$value, $v,
"Value returned" );
789 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
793 $verOpts = [
'version' => $extOpts[
'version'] + 1 ];
795 $this->assertEquals(
$value, $v,
"Value returned" );
796 $this->assertEquals( 1, $wasSet,
"Value regenerated" );
803 [ [
'version' => 1 ],
true ]
815 $priorTime = microtime(
true );
817 $t0 = $this->
cache->getCheckKeyTime( $key );
818 $this->assertGreaterThanOrEqual( $priorTime, $t0,
'Check key auto-created' );
820 $priorTime = microtime(
true );
822 $this->
cache->touchCheckKey( $key );
823 $t1 = $this->
cache->getCheckKeyTime( $key );
824 $this->assertGreaterThanOrEqual( $priorTime, $t1,
'Check key created' );
826 $t2 = $this->
cache->getCheckKeyTime( $key );
827 $this->assertEquals( $t1, $t2,
'Check key time did not change' );
830 $this->
cache->touchCheckKey( $key );
831 $t3 = $this->
cache->getCheckKeyTime( $key );
832 $this->assertGreaterThan( $t2, $t3,
'Check key time increased' );
834 $t4 = $this->
cache->getCheckKeyTime( $key );
835 $this->assertEquals( $t3, $t4,
'Check key time did not change' );
838 $this->
cache->resetCheckKey( $key );
839 $t5 = $this->
cache->getCheckKeyTime( $key );
840 $this->assertGreaterThan( $t4, $t5,
'Check key time increased' );
842 $t6 = $this->
cache->getCheckKeyTime( $key );
843 $this->assertEquals( $t5, $t6,
'Check key time did not change' );
856 $this->internalCache->set(
860 $this->internalCache->set(
864 $this->internalCache->set(
871 $v = $this->
cache->get( $key, $curTTL, [ $tKey1, $tKey2 ] );
872 $this->assertEquals(
$value, $v,
"Value matches" );
873 $this->assertLessThan( -4.9, $curTTL,
"Correct CTL" );
874 $this->assertGreaterThan( -5.1, $curTTL,
"Correct CTL" );
888 $knownPurge = time() - 60;
889 $goodTime = microtime(
true ) - 5;
890 $badTime = microtime(
true ) - 300;
892 $this->internalCache->set(
901 $this->internalCache->set(
910 $this->internalCache->set(
914 $this->internalCache->set(
919 $this->assertEquals(
$value, $this->
cache->get( $vKey1 ) );
920 $this->assertEquals(
$value, $this->
cache->get( $vKey2 ) );
921 $this->
cache->reap( $vKey1, $knownPurge, $bad1 );
922 $this->
cache->reap( $vKey2, $knownPurge, $bad2 );
924 $this->assertFalse( $bad1 );
925 $this->assertTrue( $bad2 );
927 $this->
cache->reapCheckKey( $tKey1, $knownPurge, $tBad1 );
928 $this->
cache->reapCheckKey( $tKey2, $knownPurge, $tBad2 );
929 $this->assertFalse( $tBad1 );
930 $this->assertTrue( $tBad2 );
940 $opts = [
'lag' => 300,
'since' => microtime(
true ) ];
942 $this->assertEquals(
$value, $this->
cache->get( $key ),
"Rep-lagged value written." );
945 $opts = [
'lag' => 0,
'since' => microtime(
true ) - 300 ];
947 $this->assertEquals(
false, $this->
cache->get( $key ),
"Trx-lagged value not written." );
950 $opts = [
'lag' => 5,
'since' => microtime(
true ) - 5 ];
952 $this->assertEquals(
false, $this->
cache->get( $key ),
"Lagged value not written." );
962 $opts = [
'pending' =>
true ];
964 $this->assertEquals(
false, $this->
cache->get( $key ),
"Pending value not written." );
968 $localBag = $this->getMockBuilder(
'EmptyBagOStuff' )
969 ->setMethods( [
'set',
'delete' ] )->getMock();
970 $localBag->expects( $this->never() )->method(
'set' );
971 $localBag->expects( $this->never() )->method(
'delete' );
973 'cache' => $localBag,
974 'pool' =>
'testcache-hash',
977 $valFunc =
function () {
982 $wanCache->get(
'x' );
983 $wanCache->get(
'x', $ctl, [
'check1' ] );
984 $wanCache->getMulti( [
'x',
'y' ] );
985 $wanCache->getMulti( [
'x',
'y' ], $ctls, [
'check2' ] );
986 $wanCache->getWithSetCallback(
'p', 30, $valFunc );
987 $wanCache->getCheckKeyTime(
'zzz' );
988 $wanCache->reap(
'x', time() - 300 );
989 $wanCache->reap(
'zzz', time() - 300 );
1002 $mtime = $ago ? time() - $ago : $ago;
1004 $ttl = $this->
cache->adaptiveTTL( $mtime, $maxTTL, $minTTL, $factor );
1006 $this->assertGreaterThanOrEqual( $adaptiveTTL - $margin, $ttl );
1007 $this->assertLessThanOrEqual( $adaptiveTTL + $margin, $ttl );
1009 $ttl = $this->
cache->adaptiveTTL( (
string)$mtime, $maxTTL, $minTTL, $factor );
1011 $this->assertGreaterThanOrEqual( $adaptiveTTL - $margin, $ttl );
1012 $this->assertLessThanOrEqual( $adaptiveTTL + $margin, $ttl );
1017 [ 3600, 900, 30, .2, 720 ],
1018 [ 3600, 500, 30, .2, 500 ],
1019 [ 3600, 86400, 800, .2, 800 ],
1020 [
false, 86400, 800, .2, 800 ],
1021 [
null, 86400, 800, .2, 800 ]