/** @var array (server label => host) map */
protected $serversByLabel;
/** @var string SHA-1 of the key */
/** @var array (server label => host) map */
protected $serversByLabel;
/** @var string SHA-1 of the key */
$conf['redisConfig']['serializer'] = 'none'; // for use with Lua
$this->pool = RedisConnectionPool::singleton( $conf['redisConfig'] );
$conf['redisConfig']['serializer'] = 'none'; // for use with Lua
$this->pool = RedisConnectionPool::singleton( $conf['redisConfig'] );
$this->keySha1 = sha1( $this->key );
$met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
$this->lockTTL = $met ? 2 * $met : 3600;
if ( self::$active === null ) {
$this->keySha1 = sha1( $this->key );
$met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
$this->lockTTL = $met ? 2 * $met : 3600;
if ( self::$active === null ) {
$servers = $this->ring->getLocations( $this->key, 3 );
ArrayUtils::consistentHashSort( $servers, $this->key );
foreach ( $servers as $server ) {
$servers = $this->ring->getLocations( $this->key, 3 );
ArrayUtils::consistentHashSort( $servers, $this->key );
foreach ( $servers as $server ) {
<<<LUA
local kSlots,kSlotsNextRelease,kWakeup,kWaiting = unpack(KEYS)
local rMaxWorkers,rExpiry,rSlot,rSlotTime,rAwakeAll,rTime = unpack(ARGV)
<<<LUA
local kSlots,kSlotsNextRelease,kWakeup,kWaiting = unpack(KEYS)
local rMaxWorkers,rExpiry,rSlot,rSlotTime,rAwakeAll,rTime = unpack(ARGV)
$this->getSlotListKey(),
$this->getSlotRTimeSetKey(),
$this->getWakeupListKey(),
$this->getSlotListKey(),
$this->getSlotRTimeSetKey(),
$this->getWakeupListKey(),
$this->slotTime, // used for CAS-style sanity check
( $this->onRelease === self::AWAKE_ALL ) ? 1 : 0,
microtime( true )
$this->slotTime, // used for CAS-style sanity check
( $this->onRelease === self::AWAKE_ALL ) ? 1 : 0,
microtime( true )
} elseif ( $slot === 'QUEUE_WAIT' ) {
// This process is now registered as waiting
$keys = ( $doWakeup == self::AWAKE_ALL )
} elseif ( $slot === 'QUEUE_WAIT' ) {
// This process is now registered as waiting
$keys = ( $doWakeup == self::AWAKE_ALL )
- // Wait for an open slot or wake-up signal (preferring the later)
- ? array( $this->getWakeupListKey(), $this->getSlotListKey() )
+ // Wait for an open slot or wake-up signal (preferring the latter)
+ ? [ $this->getWakeupListKey(), $this->getSlotListKey() ]
$conn->zRem( $this->getWaitSetKey(), $this->session ); // no longer waiting
return Status::newGood( PoolCounter::TIMEOUT );
}
$conn->zRem( $this->getWaitSetKey(), $this->session ); // no longer waiting
return Status::newGood( PoolCounter::TIMEOUT );
}
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rMaxWorkers,rMaxQueue,rTimeout,rExpiry,rSess,rTime = unpack(ARGV)
-- Initialize if the "next release" time sorted-set is empty. The slot key
-- itself is empty if all slots are busy or when nothing is initialized.
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rMaxWorkers,rMaxQueue,rTimeout,rExpiry,rSess,rTime = unpack(ARGV)
-- Initialize if the "next release" time sorted-set is empty. The slot key
-- itself is empty if all slots are busy or when nothing is initialized.
-- For sanity, if the list exists but not the set, then reset everything.
if redis.call('exists',kSlotsNextRelease) == 0 then
redis.call('del',kSlots)
-- For sanity, if the list exists but not the set, then reset everything.
if redis.call('exists',kSlotsNextRelease) == 0 then
redis.call('del',kSlots)
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rSlot,rExpiry,rSess,rTime = unpack(ARGV)
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rSlot,rExpiry,rSess,rTime = unpack(ARGV)