Extended TimeSeries support by implementing TS.INFO command (#1228)

* Added support for new arguments for BITPOS, BITCOUNT commands (#1045)

* Added support for new arguments for EXPIRE, EXPIREAT commands (#1046)

* Extended core support by implementing SORT_RO command (#1044)

* Added support for SORT_RO command

* Codestyle fixes

* Added command description

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* fix deprecated call

* Added support for container commands (#1049)

* Added support for container commands FUNCTION LOAD, FUNCTION DELETE and FCALL

* Changed ContainerInterface and AbstractContainer

* Re-implement logic of abstract methods

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Added stream commands to KeyPrefixProcessor (#1051)

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Fix return type of ReplicationInterface::getSlaves (#1111)

* Codestyle fixes

* Changed return annotation

* Added support for TS.INFO command

* Rename method to be more consistent

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>
Co-authored-by: Till Krüss <till@kruss.io>
Co-authored-by: Stephan <glaubinix@users.noreply.github.com>
This commit is contained in:
Vladyslav Vildanov
2023-03-28 16:45:19 +03:00
committed by GitHub
parent 55ce9cd2f4
commit 69ba5d77aa
27 changed files with 311 additions and 43 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -31,7 +31,7 @@ $client->tscreate('temperature:2:32', $arguments);
// 2. Add sample into newly created time series
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$response = $client->tsadd('temperature:2:32', 123123123123, 27, $addArguments);
+1 -1
View File
@@ -23,7 +23,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
+1 -1
View File
@@ -22,7 +22,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
+2 -2
View File
@@ -24,7 +24,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -32,7 +32,7 @@ $client->tscreate('temperature:2:32', $arguments);
// 2. Add sample into newly created time series
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$response = $client->tsadd('temperature:2:32', 123123123123, 27, $addArguments);
+1 -1
View File
@@ -21,7 +21,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
+1 -1
View File
@@ -21,7 +21,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
+2 -2
View File
@@ -24,7 +24,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -32,7 +32,7 @@ $client->tscreate('temperature:2:32', $arguments);
// 2. Add sample into newly created time series
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$response = $client->tsadd('temperature:2:32', 123123123123, 27, $addArguments);
+32
View File
@@ -0,0 +1,32 @@
<?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.
*/
use Predis\Client;
use Predis\Command\Argument\TimeSeries\CommonArguments;
use Predis\Command\Argument\TimeSeries\CreateArguments;
require __DIR__ . '/../../shared.php';
// Example of TS.CREATE command usage:
// 1. Create time series
$client = new Client();
$arguments = (new CreateArguments())
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
$client->tscreate('temperature:2:32', $arguments);
// 2. Show info about given time series
print_r($client->tsinfo('temperature:2:32'));
+1 -1
View File
@@ -22,7 +22,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
+1 -1
View File
@@ -23,7 +23,7 @@ require __DIR__ . '/../../shared.php';
$client = new Client();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('type', 'temp', 'sensor_id', 2, 'area_id', 32);
+2
View File
@@ -33,6 +33,7 @@ use Predis\Command\Argument\TimeSeries\CreateArguments as TSCreateArguments;
use Predis\Command\Argument\TimeSeries\DecrByArguments;
use Predis\Command\Argument\TimeSeries\GetArguments;
use Predis\Command\Argument\TimeSeries\IncrByArguments;
use Predis\Command\Argument\TimeSeries\InfoArguments;
use Predis\Command\Argument\TimeSeries\MGetArguments;
use Predis\Command\CommandInterface;
use Predis\Command\Container\FUNCTIONS;
@@ -246,6 +247,7 @@ use Predis\Command\Container\Search\FTCONFIG;
* @method $this tsdel(string $key, int $fromTimestamp, int $toTimestamp)
* @method $this tsget(string $key, GetArguments $arguments = null)
* @method $this tsincrby(string $key, float $value, ?IncrByArguments $arguments = null)
* @method $this tsinfo(string $key, ?InfoArguments $arguments = null)
* @method $this tsmadd(mixed ...$keyTimestampValue)
* @method $this tsmget(MGetArguments $arguments, string ...$filterExpression)
* @method $this zadd($key, array $membersAndScoresDictionary)
+2
View File
@@ -33,6 +33,7 @@ use Predis\Command\Argument\TimeSeries\CreateArguments as TSCreateArguments;
use Predis\Command\Argument\TimeSeries\DecrByArguments;
use Predis\Command\Argument\TimeSeries\GetArguments;
use Predis\Command\Argument\TimeSeries\IncrByArguments;
use Predis\Command\Argument\TimeSeries\InfoArguments;
use Predis\Command\Argument\TimeSeries\MGetArguments;
use Predis\Command\CommandInterface;
use Predis\Command\Container\FUNCTIONS;
@@ -256,6 +257,7 @@ use Predis\Response\Status;
* @method int tsdel(string $key, int $fromTimestamp, int $toTimestamp)
* @method array tsget(string $key, GetArguments $arguments = null)
* @method int tsincrby(string $key, float $value, ?IncrByArguments $arguments = null)
* @method array tsinfo(string $key, ?InfoArguments $arguments = null)
* @method array tsmadd(mixed ...$keyTimestampValue)
* @method array tsmget(MGetArguments $arguments, string ...$filterExpression)
* @method string xadd(string $key, array $dictionary, string $id = '*', array $options = null)
@@ -37,7 +37,7 @@ class CommonArguments implements ArrayableArgument
* @param int $retentionPeriod
* @return $this
*/
public function retention(int $retentionPeriod): self
public function retentionMsecs(int $retentionPeriod): self
{
array_push($this->arguments, 'RETENTION', $retentionPeriod);
@@ -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;
}
}
+39
View File
@@ -0,0 +1,39 @@
<?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\Redis\TimeSeries;
use Predis\Command\Command as RedisCommand;
/**
* @see https://redis.io/commands/ts.info/
*
* Return information and statistics for a time series.
*/
class TSINFO extends RedisCommand
{
public function getId()
{
return 'TS.INFO';
}
public function setArguments(array $arguments)
{
[$key] = $arguments;
$commandArguments = (!empty($arguments[1])) ? $arguments[1]->toArray() : [];
parent::setArguments(array_merge(
[$key],
$commandArguments
));
}
}
@@ -31,7 +31,7 @@ class CommonArgumentsTest extends TestCase
*/
public function testCreatesArgumentsWithRetentionModifier(): void
{
$this->arguments->retention(10);
$this->arguments->retentionMsecs(10);
$this->assertSame(['RETENTION', 10], $this->arguments->toArray());
}
@@ -0,0 +1,38 @@
<?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 PHPUnit\Framework\TestCase;
class InfoArgumentsTest extends TestCase
{
/**
* @var InfoArguments
*/
private $arguments;
protected function setUp(): void
{
$this->arguments = new InfoArguments();
}
/**
* @return void
*/
public function testCreatesArgumentsWithDebugModifier(): void
{
$this->arguments->debug();
$this->assertSame(['DEBUG'], $this->arguments->toArray());
}
}
@@ -65,7 +65,7 @@ class TSADD_Test extends PredisCommandTestCase
$redis = $this->getClient();
$createArguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -75,7 +75,7 @@ class TSADD_Test extends PredisCommandTestCase
);
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$this->assertEquals(
123123123123,
@@ -91,7 +91,7 @@ class TSADD_Test extends PredisCommandTestCase
['key', 123123121321, 1.0],
],
'with RETENTION modifier' => [
['key', 123123121321, 1.0, (new AddArguments())->retention(100)],
['key', 123123121321, 1.0, (new AddArguments())->retentionMsecs(100)],
['key', 123123121321, 1.0, 'RETENTION', 100],
],
'with ENCODING modifier' => [
@@ -107,7 +107,7 @@ class TSADD_Test extends PredisCommandTestCase
['key', 123123121321, 1.0, 'ON_DUPLICATE', CommonArguments::POLICY_FIRST],
],
'with all modifiers' => [
['key', 123123121321, 1.0, (new AddArguments())->retention(100)->encoding(CommonArguments::ENCODING_UNCOMPRESSED)->chunkSize(100)->onDuplicate(CommonArguments::POLICY_FIRST)],
['key', 123123121321, 1.0, (new AddArguments())->retentionMsecs(100)->encoding(CommonArguments::ENCODING_UNCOMPRESSED)->chunkSize(100)->onDuplicate(CommonArguments::POLICY_FIRST)],
['key', 123123121321, 1.0, 'RETENTION', 100, 'ENCODING', CommonArguments::ENCODING_UNCOMPRESSED, 'CHUNK_SIZE', 100, 'ON_DUPLICATE', CommonArguments::POLICY_FIRST],
],
];
@@ -66,7 +66,7 @@ class TSALTER_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -76,7 +76,7 @@ class TSALTER_Test extends PredisCommandTestCase
);
$alterArguments = (new AlterArguments())
->retention(10000000);
->retentionMsecs(10000000);
$this->assertEquals(
'OK',
@@ -107,7 +107,7 @@ class TSALTER_Test extends PredisCommandTestCase
['key'],
],
'with RETENTION modifier' => [
['key', (new AlterArguments())->retention(100)],
['key', (new AlterArguments())->retentionMsecs(100)],
['key', 'RETENTION', 100],
],
'with CHUNK_SIZE modifier' => [
@@ -119,7 +119,7 @@ class TSALTER_Test extends PredisCommandTestCase
['key', 'DUPLICATE_POLICY', CommonArguments::POLICY_FIRST],
],
'with all modifiers' => [
['key', (new AlterArguments())->retention(100)->chunkSize(100)->duplicatePolicy(CommonArguments::POLICY_FIRST)],
['key', (new AlterArguments())->retentionMsecs(100)->chunkSize(100)->duplicatePolicy(CommonArguments::POLICY_FIRST)],
['key', 'RETENTION', 100, 'CHUNK_SIZE', 100, 'DUPLICATE_POLICY', CommonArguments::POLICY_FIRST],
],
];
@@ -15,6 +15,7 @@ namespace Predis\Command\Redis\TimeSeries;
use Predis\Command\Argument\TimeSeries\CommonArguments;
use Predis\Command\Argument\TimeSeries\CreateArguments;
use Predis\Command\Redis\PredisCommandTestCase;
use Predis\Response\ServerException;
class TSCREATE_Test extends PredisCommandTestCase
{
@@ -64,7 +65,7 @@ class TSCREATE_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -74,6 +75,21 @@ class TSCREATE_Test extends PredisCommandTestCase
);
}
/**
* @group connected
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
public function testThrowsExceptionOnNonExistingKey(): void
{
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('ERR TSDB: the key does not exist');
$redis->tsinfo('non_existing_key');
}
public function argumentsProvider(): array
{
return [
@@ -82,7 +98,7 @@ class TSCREATE_Test extends PredisCommandTestCase
['key'],
],
'with RETENTION modifier' => [
['key', (new CreateArguments())->retention(100)],
['key', (new CreateArguments())->retentionMsecs(100)],
['key', 'RETENTION', 100],
],
'with ENCODING modifier' => [
@@ -98,7 +114,7 @@ class TSCREATE_Test extends PredisCommandTestCase
['key', 'DUPLICATE_POLICY', CommonArguments::POLICY_FIRST],
],
'with all modifiers' => [
['key', (new CreateArguments())->retention(100)->encoding(CreateArguments::ENCODING_UNCOMPRESSED)->chunkSize(100)->duplicatePolicy(CommonArguments::POLICY_FIRST)],
['key', (new CreateArguments())->retentionMsecs(100)->encoding(CreateArguments::ENCODING_UNCOMPRESSED)->chunkSize(100)->duplicatePolicy(CommonArguments::POLICY_FIRST)],
['key', 'RETENTION', 100, 'ENCODING', CreateArguments::ENCODING_UNCOMPRESSED, 'CHUNK_SIZE', 100, 'DUPLICATE_POLICY', CommonArguments::POLICY_FIRST],
],
];
@@ -67,7 +67,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -77,7 +77,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
);
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$this->assertEquals(
123123123123,
@@ -100,7 +100,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -125,7 +125,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -135,7 +135,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
);
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$this->assertEquals(
123123123123,
@@ -160,7 +160,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
['key', 1.0, 'TIMESTAMP', 10],
],
'with RETENTION modifier' => [
['key', 1.0, (new DecrByArguments())->retention(100)],
['key', 1.0, (new DecrByArguments())->retentionMsecs(100)],
['key', 1.0, 'RETENTION', 100],
],
'with UNCOMPRESSED modifier' => [
@@ -176,7 +176,7 @@ class TSDECRBY_Test extends PredisCommandTestCase
['key', 1.0, 'LABELS', 'label1', 1, 'label2', 2],
],
'with all modifiers' => [
['key', 1.0, (new DecrByArguments())->timestamp(10)->retention(100)->uncompressed()->chunkSize(100)->labels('label1', 1, 'label2', 2)],
['key', 1.0, (new DecrByArguments())->timestamp(10)->retentionMsecs(100)->uncompressed()->chunkSize(100)->labels('label1', 1, 'label2', 2)],
['key', 1.0, 'TIMESTAMP', 10, 'RETENTION', 100, 'UNCOMPRESSED', 'CHUNK_SIZE', 100, 'LABELS', 'label1', 1, 'label2', 2],
],
];
@@ -67,7 +67,7 @@ class TSDEL_Test extends PredisCommandTestCase
$redis = $this->getClient();
$createArguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -66,7 +66,7 @@ class TSGET_Test extends PredisCommandTestCase
$redis = $this->getClient();
$createArguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -67,7 +67,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -77,7 +77,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
);
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$this->assertEquals(
123123123123,
@@ -100,7 +100,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -125,7 +125,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
$redis = $this->getClient();
$arguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -135,7 +135,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
);
$addArguments = (new AddArguments())
->retention(31536000000);
->retentionMsecs(31536000000);
$this->assertEquals(
123123123123,
@@ -160,7 +160,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
['key', 1.0, 'TIMESTAMP', 10],
],
'with RETENTION modifier' => [
['key', 1.0, (new IncrByArguments())->retention(100)],
['key', 1.0, (new IncrByArguments())->retentionMsecs(100)],
['key', 1.0, 'RETENTION', 100],
],
'with UNCOMPRESSED modifier' => [
@@ -176,7 +176,7 @@ class TSINCRBY_Test extends PredisCommandTestCase
['key', 1.0, 'LABELS', 'label1', 1, 'label2', 2],
],
'with all modifiers' => [
['key', 1.0, (new IncrByArguments())->timestamp(10)->retention(100)->uncompressed()->chunkSize(100)->labels('label1', 1, 'label2', 2)],
['key', 1.0, (new IncrByArguments())->timestamp(10)->retentionMsecs(100)->uncompressed()->chunkSize(100)->labels('label1', 1, 'label2', 2)],
['key', 1.0, 'TIMESTAMP', 10, 'RETENTION', 100, 'UNCOMPRESSED', 'CHUNK_SIZE', 100, 'LABELS', 'label1', 1, 'label2', 2],
],
];
@@ -0,0 +1,96 @@
<?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\Redis\TimeSeries;
use Predis\Command\Argument\TimeSeries\CommonArguments;
use Predis\Command\Argument\TimeSeries\CreateArguments;
use Predis\Command\Argument\TimeSeries\InfoArguments;
use Predis\Command\Redis\PredisCommandTestCase;
class TSINFO_Test extends PredisCommandTestCase
{
/**
* {@inheritDoc}
*/
protected function getExpectedCommand(): string
{
return TSINFO::class;
}
/**
* {@inheritDoc}
*/
protected function getExpectedId(): string
{
return 'TSINFO';
}
/**
* @group disconnected
* @dataProvider argumentsProvider
*/
public function testFilterArguments(array $actualArguments, array $expectedArguments): void
{
$command = $this->getCommand();
$command->setArguments($actualArguments);
$this->assertSameValues($expectedArguments, $command->getArguments());
}
/**
* @group disconnected
*/
public function testParseResponse(): void
{
$this->assertSame(1, $this->getCommand()->parseResponse(1));
}
/**
* @group connected
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
public function testReturnsInformationAboutGivenTimeSeries(): void
{
$redis = $this->getClient();
$expectedResponse = ['totalSamples', 0, 'memoryUsage', 4239, 'firstTimestamp', 0, 'lastTimestamp', 0,
'retentionTime', 60000, 'chunkCount', 1, 'chunkSize', 4096, 'chunkType', 'compressed', 'duplicatePolicy',
'max', 'labels', [['sensor_id', '2'], ['area_id', '32']], 'sourceKey', null, 'rules', []];
$arguments = (new CreateArguments())
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
$this->assertEquals(
'OK',
$redis->tscreate('temperature:2:32', $arguments)
);
$this->assertEquals($expectedResponse, $redis->tsinfo('temperature:2:32'));
}
public function argumentsProvider(): array
{
return [
'with default arguments' => [
['key'],
['key'],
],
'with DEBUG modifier' => [
['key', (new InfoArguments())->debug()],
['key', 'DEBUG'],
],
];
}
}
@@ -67,7 +67,7 @@ class TSMADD_Test extends PredisCommandTestCase
$redis = $this->getClient();
$createArguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('sensor_id', 2, 'area_id', 32);
@@ -69,7 +69,7 @@ class TSMGET_Test extends PredisCommandTestCase
];
$createArguments = (new CreateArguments())
->retention(60000)
->retentionMsecs(60000)
->duplicatePolicy(CommonArguments::POLICY_MAX)
->labels('type', 'temp', 'sensor_id', 2, 'area_id', 32);