mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 19:58:22 +08:00
commit
3649f9391f
@ -72,32 +72,28 @@ class Meta
|
||||
$this->sequence = $sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $timestamp
|
||||
* @return Meta
|
||||
*/
|
||||
public function setTimestamp(int $timestamp): self
|
||||
{
|
||||
$this->timestamp = $timestamp;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function maxMachineId()
|
||||
protected function maxMachineId(): int
|
||||
{
|
||||
return -1 ^ (-1 << self::MACHINE_ID_BITS);
|
||||
}
|
||||
|
||||
protected function maxDataCenterId()
|
||||
protected function maxDataCenterId(): int
|
||||
{
|
||||
return -1 ^ (-1 << self::DATA_CENTER_ID_BITS);
|
||||
}
|
||||
|
||||
protected function maxBusinessId()
|
||||
protected function maxBusinessId(): int
|
||||
{
|
||||
return -1 ^ (-1 << self::BUSINESS_ID_BITS);
|
||||
}
|
||||
|
||||
protected function maxSequence()
|
||||
protected function maxSequence(): int
|
||||
{
|
||||
return -1 ^ (-1 << self::SEQUENCE_BITS);
|
||||
}
|
||||
|
@ -65,22 +65,22 @@ class Snowflake implements IdGeneratorInterface
|
||||
))->setTimestamp($timestamp + $this->beginSecond);
|
||||
}
|
||||
|
||||
protected function getTimestampShift()
|
||||
protected function getTimestampShift(): int
|
||||
{
|
||||
return Meta::SEQUENCE_BITS + Meta::MACHINE_ID_BITS + Meta::DATA_CENTER_ID_BITS + Meta::BUSINESS_ID_BITS;
|
||||
}
|
||||
|
||||
protected function getBusinessIdShift()
|
||||
protected function getBusinessIdShift(): int
|
||||
{
|
||||
return Meta::SEQUENCE_BITS + Meta::MACHINE_ID_BITS + Meta::DATA_CENTER_ID_BITS;
|
||||
}
|
||||
|
||||
protected function getDataCenterShift()
|
||||
protected function getDataCenterShift(): int
|
||||
{
|
||||
return Meta::SEQUENCE_BITS + Meta::MACHINE_ID_BITS;
|
||||
}
|
||||
|
||||
protected function getMachineIdShift()
|
||||
protected function getMachineIdShift(): int
|
||||
{
|
||||
return Meta::SEQUENCE_BITS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user