// For hot keys, either another thread has the lock or the lock failed;
// use the INTERIM value from the last thread that regenerated it.
$wrapped = $this->cache->get( self::INTERIM_KEY_PREFIX . $key );
- $value = $this->unwrap( $wrapped, microtime( true ) );
+ list( $value ) = $this->unwrap( $wrapped, microtime( true ) );
if ( $value !== false && $this->isValid( $value, $versioned, $asOf, $minTime ) ) {
$asOf = $wrapped[self::FLD_TIME];
// Acquire a lock to verify that getWithSetCallback uses lockTSE properly
$this->internalCache->lock( $key, 0 );
- $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
+
+ $checkKeys = [ wfRandomString() ]; // new check keys => force misses
+ $ret = $cache->getWithSetCallback( $key, 30, $func,
+ [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] );
$this->assertEquals( $value, $ret );
$this->assertEquals( 1, $calls, 'Callback was not used' );
+
+ $cache->delete( $key );
+ $ret = $cache->getWithSetCallback( $key, 30, $func,
+ [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] ); // should use interim value
+ $this->assertEquals( $value, $ret );
+ $this->assertEquals( 2, $calls, 'Callback was used' );
+
+ $ret = $cache->getWithSetCallback( $key, 30, $func,
+ [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] );
+ $this->assertEquals( $value, $ret );
+ $this->assertEquals( 2, $calls, 'Callback was not used; used interim' );
}
/**