Predis to v2.2.2

This commit is contained in:
the-djmaze 2024-04-08 16:29:55 +02:00
parent 9510347d3a
commit 969dca5f7e
449 changed files with 22013 additions and 2 deletions

View file

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class AddArguments extends CommonArguments
{
/**
* Is overwrite key and database configuration for DUPLICATE_POLICY,
* the policy for handling samples with identical timestamps.
*
* @param string $policy
* @return $this
*/
public function onDuplicate(string $policy = self::POLICY_BLOCK): self
{
array_push($this->arguments, 'ON_DUPLICATE', $policy);
return $this;
}
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class AlterArguments extends CommonArguments
{
}

View file

@ -0,0 +1,143 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
use Predis\Command\Argument\ArrayableArgument;
class CommonArguments implements ArrayableArgument
{
public const POLICY_BLOCK = 'BLOCK';
public const POLICY_FIRST = 'FIRST';
public const POLICY_LAST = 'LAST';
public const POLICY_MIN = 'MIN';
public const POLICY_MAX = 'MAX';
public const POLICY_SUM = 'SUM';
public const ENCODING_UNCOMPRESSED = 'UNCOMPRESSED';
public const ENCODING_COMPRESSED = 'COMPRESSED';
/**
* @var array
*/
protected $arguments = [];
/**
* Is maximum age for samples compared to the highest reported timestamp, in milliseconds.
*
* @param int $retentionPeriod
* @return $this
*/
public function retentionMsecs(int $retentionPeriod): self
{
array_push($this->arguments, 'RETENTION', $retentionPeriod);
return $this;
}
/**
* Is initial allocation size, in bytes, for the data part of each new chunk.
*
* @param int $size
* @return $this
*/
public function chunkSize(int $size): self
{
array_push($this->arguments, 'CHUNK_SIZE', $size);
return $this;
}
/**
* Is policy for handling insertion of multiple samples with identical timestamps.
*
* @param string $policy
* @return $this
*/
public function duplicatePolicy(string $policy = self::POLICY_BLOCK): self
{
array_push($this->arguments, 'DUPLICATE_POLICY', $policy);
return $this;
}
/**
* Is set of label-value pairs that represent metadata labels of the key and serve as a secondary index.
*
* @param mixed ...$labelValuePair
* @return $this
*/
public function labels(...$labelValuePair): self
{
array_push($this->arguments, 'LABELS', ...$labelValuePair);
return $this;
}
/**
* Specifies the series samples encoding format.
*
* @param string $encoding
* @return $this
*/
public function encoding(string $encoding = self::ENCODING_COMPRESSED): self
{
array_push($this->arguments, 'ENCODING', $encoding);
return $this;
}
/**
* Is used when a time series is a compaction.
* With LATEST, TS.GET reports the compacted value of the latest, possibly partial, bucket.
*
* @return $this
*/
public function latest(): self
{
$this->arguments[] = 'LATEST';
return $this;
}
/**
* Includes in the reply all label-value pairs representing metadata labels of the time series.
*
* @return $this
*/
public function withLabels(): self
{
$this->arguments[] = 'WITHLABELS';
return $this;
}
/**
* Returns a subset of the label-value pairs that represent metadata labels of the time series.
*
* @return $this
*/
public function selectedLabels(string ...$labels): self
{
array_push($this->arguments, 'SELECTED_LABELS', ...$labels);
return $this;
}
/**
* {@inheritDoc}
*/
public function toArray(): array
{
return $this->arguments;
}
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class CreateArguments extends CommonArguments
{
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class DecrByArguments extends IncrByArguments
{
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class GetArguments extends CommonArguments
{
}

View file

@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class IncrByArguments extends CommonArguments
{
/**
* Is (integer) UNIX sample timestamp in milliseconds or * to set the timestamp according to the server clock.
*
* @param string|int $timeStamp
* @return $this
*/
public function timestamp($timeStamp): self
{
array_push($this->arguments, 'TIMESTAMP', $timeStamp);
return $this;
}
/**
* Changes data storage from compressed (default) to uncompressed.
*
* @return $this
*/
public function uncompressed(): self
{
$this->arguments[] = 'UNCOMPRESSED';
return $this;
}
}

View file

@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
use Predis\Command\Argument\ArrayableArgument;
class InfoArguments implements ArrayableArgument
{
/**
* @var array
*/
private $arguments = [];
/**
* Is an optional flag to get a more detailed information about the chunks.
*
* @return $this
*/
public function debug(): self
{
$this->arguments[] = 'DEBUG';
return $this;
}
/**
* {@inheritDoc}
*/
public function toArray(): array
{
return $this->arguments;
}
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class MGetArguments extends CommonArguments
{
}

View file

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class MRangeArguments extends RangeArguments
{
/**
* Filters time series based on their labels and label values.
*
* @param string ...$filterExpressions
* @return $this
*/
public function filter(string ...$filterExpressions): self
{
array_push($this->arguments, 'FILTER', ...$filterExpressions);
return $this;
}
/**
* Splits time series into groups, each group contains time series that share the same
* value for the provided label name, then aggregates results in each group.
*
* @param string $label
* @param string $reducer
* @return $this
*/
public function groupBy(string $label, string $reducer): self
{
array_push($this->arguments, 'GROUPBY', $label, 'REDUCE', $reducer);
return $this;
}
}

View file

@ -0,0 +1,85 @@
<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Argument\TimeSeries;
class RangeArguments extends CommonArguments
{
/**
* Filters samples by a list of specific timestamps.
*
* @param int ...$ts
* @return $this
*/
public function filterByTs(int ...$ts): self
{
array_push($this->arguments, 'FILTER_BY_TS', ...$ts);
return $this;
}
/**
* Filters samples by minimum and maximum values.
*
* @param int $min
* @param int $max
* @return $this
*/
public function filterByValue(int $min, int $max): self
{
array_push($this->arguments, 'FILTER_BY_VALUE', $min, $max);
return $this;
}
/**
* Limits the number of returned samples.
*
* @param int $count
* @return $this
*/
public function count(int $count): self
{
array_push($this->arguments, 'COUNT', $count);
return $this;
}
/**
* Aggregates samples into time buckets.
*
* @param string $aggregator
* @param int $bucketDuration Is duration of each bucket, in milliseconds.
* @param int $align It controls the time bucket timestamps by changing the reference timestamp on which a bucket is defined.
* @param int $bucketTimestamp Controls how bucket timestamps are reported.
* @param bool $empty Is a flag, which, when specified, reports aggregations also for empty buckets.
* @return $this
*/
public function aggregation(string $aggregator, int $bucketDuration, int $align = 0, int $bucketTimestamp = 0, bool $empty = false): self
{
if ($align > 0) {
array_push($this->arguments, 'ALIGN', $align);
}
array_push($this->arguments, 'AGGREGATION', $aggregator, $bucketDuration);
if ($bucketTimestamp > 0) {
array_push($this->arguments, 'BUCKETTIMESTAMP', $bucketTimestamp);
}
if (true === $empty) {
$this->arguments[] = 'EMPTY';
}
return $this;
}
}