const READ_VERIFIED = 2; // promise that caller can tell when keys are stale
/** Bitfield constants for set()/merge() */
const WRITE_SYNC = 1; // synchronously write to all locations for replicated stores
+ const WRITE_CACHE_ONLY = 2; // Only change state of the in-memory cache
public function __construct( array $params = array() ) {
if ( isset( $params['logger'] ) ) {
}
$lSince = microtime( true ); // lock timestamp
- // PHP 5.3: Can't use $this in a closure
- $that = $this;
- $logger = $this->logger;
- return new ScopedCallback( function() use ( $that, $logger, $key, $lSince, $expiry ) {
+ return new ScopedCallback( function() use ( $key, $lSince, $expiry ) {
$latency = .050; // latency skew (err towards keeping lock present)
$age = ( microtime( true ) - $lSince + $latency );
if ( ( $age + $latency ) >= $expiry ) {
- $logger->warning( "Lock for $key held too long ($age sec)." );
+ $this->logger->warning( "Lock for $key held too long ($age sec)." );
return; // expired; it's not "safe" to delete the key
}
- $that->unlock( $key );
+ $this->unlock( $key );
} );
}