49 lines
957 B
PHP
49 lines
957 B
PHP
<?php
|
|
|
|
namespace Toalett\Redis\Timeseries\Model;
|
|
|
|
final class Retention
|
|
{
|
|
private int $value;
|
|
|
|
private function __construct(int $value)
|
|
{
|
|
$this->value = $value;
|
|
}
|
|
|
|
public function getValue(): int
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public static function indefinite(): Retention
|
|
{
|
|
return new self(0);
|
|
}
|
|
|
|
public static function milliseconds(int $milliseconds): Retention
|
|
{
|
|
return new self($milliseconds);
|
|
}
|
|
|
|
public static function seconds(int $seconds): Retention
|
|
{
|
|
return new self(1000 * $seconds);
|
|
}
|
|
|
|
public static function minutes(int $minutes): Retention
|
|
{
|
|
return new self(60 * 1000 * $minutes);
|
|
}
|
|
|
|
public static function hours(int $hours): Retention
|
|
{
|
|
return new self(60 * 60 * 1000 * $hours);
|
|
}
|
|
|
|
public static function days(int $days): Retention
|
|
{
|
|
return new self(24 * 60 * 60 * 1000 * $days);
|
|
}
|
|
}
|