{"id":27697877,"url":"https://github.com/palicao/phpredistimeseries","last_synced_at":"2025-04-25T16:21:33.538Z","repository":{"id":48800851,"uuid":"211956264","full_name":"palicao/phpRedisTimeSeries","owner":"palicao","description":"📈 Use Redis Time Series in PHP!","archived":false,"fork":false,"pushed_at":"2024-01-27T09:19:54.000Z","size":115,"stargazers_count":28,"open_issues_count":8,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-20T13:07:04.896Z","etag":null,"topics":["driver","php","phpredis","predis","redis","redis-server","timeseries"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palicao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-09-30T21:00:34.000Z","updated_at":"2023-12-13T19:14:51.000Z","dependencies_parsed_at":"2024-01-27T09:35:54.074Z","dependency_job_id":null,"html_url":"https://github.com/palicao/phpRedisTimeSeries","commit_stats":{"total_commits":45,"total_committers":6,"mean_commits":7.5,"dds":"0.37777777777777777","last_synced_commit":"3b53ffa5e23e7032e2c68a1795100fa4906ce5fa"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRedisTimeSeries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRedisTimeSeries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRedisTimeSeries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palicao%2FphpRedisTimeSeries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palicao","download_url":"https://codeload.github.com/palicao/phpRedisTimeSeries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250850385,"owners_count":21497498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","php","phpredis","predis","redis","redis-server","timeseries"],"created_at":"2025-04-25T16:21:32.709Z","updated_at":"2025-04-25T16:21:33.532Z","avatar_url":"https://github.com/palicao.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phpRedisTimeSeries\n\nUse [Redis Time Series](https://oss.redislabs.com/redistimeseries/) in PHP!\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/fea927b90378dd63a9d8/maintainability)](https://codeclimate.com/github/palicao/phpRedisTimeSeries/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/fea927b90378dd63a9d8/test_coverage)](https://codeclimate.com/github/palicao/phpRedisTimeSeries/test_coverage)\n[![Build Status](https://github.com/palicao/phpRedisTimeSeries/actions/workflows/main.yml/badge.svg)](https://travis-ci.com/palicao/phpRedisTimeSeries)\n[![Latest Stable Version](https://img.shields.io/packagist/v/palicao/php-redis-time-series.svg)](https://packagist.org/packages/palicao/php-redis-time-series)\n![PHP version](https://img.shields.io/packagist/php-v/palicao/php-redis-time-series/2.0.0)\n![GitHub](https://img.shields.io/github/license/palicao/phpRedisTimeSeries)\n\n## Getting up and running\n\n### Install\n`composer require palicao/php-redis-time-series`\n\n### Requirements\nThe library is tested against:\n- PHP 7.2, 7.3, 7.4, 8.0\n- RedisTimeSeries 1.4.10 (but it should work with any 1.4 version)\n\nIn order to use RedisTimeSeries 1.2 please use version 2.1.1 of this library.\n\n### Construct\n```\n$ts = new TimeSeries(\n    new RedisClient(\n        new Redis(),\n        new RedisConnectionParams($host, $port)\n    )\n);\n```\n\n## `TimeSeries` methods\n\n### `create`\n\n`TimeSeries::create(string $key, ?int $retentionMs = null, array $labels = []): void`\n\nCreates a key, optionally setting a retention time (in milliseconds) and some labels.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tscreate.\n\n### `alter`\n\n`TimeSeries::alter(string $key, ?int $retentionMs = null, array $labels = []): void`\n \nModifies an existing key's retention time and/or labels.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsalter.\n \n### `add`\n \n`TimeSeries::add(Sample $sample, ?int $retentionMs = null, array $labels = []): Sample`\n  \nAdds a sample.\n\nIf the key was not explicitly `create`d, it's possible to set retention and labels.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsadd.\n\nExamples: \n* `$sample = $ts-\u003eadd(new Sample('myKey', 32.10), 10, [new Label('myLabel', 'myValue')]);` Adds a sample to `myKey` at \nthe current timestamp (time of the redis server) and returns it (complete with dateTime).\n* `$sample = $ts-\u003eadd(new Sample('myKey', 32.10, new DateTimeImmutable()), 10, [new Label('myLabel', 'myValue')]);`\nAdds a sample to `myKey` at a given datetime and returns it.\n\nPlease notice that RedisTimeSeries only allows to add samples in order (no sample older than the latest is allowed)\n\n### `addMany`\n\n`TimeSeries::addMany(array $samples): array`\n\nAdds several samples.\n\nAs usual, if no timestamp is provided, the redis server current time is used. Added samples are returned in an array.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsmadd.\n\n### `incrementBy` and `decrementBy`\n\n`TimeSeries::incrementBy(Sample $sample, ?int $resetMs = null, ?int $retentionMs = null, array $labels = []): void`\n\n`TimeSeries::decrementBy(Sample $sample, ?int $resetMs = null, ?int $retentionMs = null, array $labels = []): void`\n\nAdd a sample to a key, incrementing or decrementing the last value by an amount specified in `$sample`.\nThe value can be optionally reset after `$resetMs` milliseconds.\n\nSimilarly to `add`, if the command is used on a non-existing key, it's possible to set retention and labels. \n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsincrbytsdecrby.\n\n### `createRule`\n\n`TimeSeries::createRule(string $sourceKey, string $destKey, AggregationRule $rule): void`\n\nCreates an aggregation rule which applies the given `$rule` to `$sourceKey` in order to populate `$destKey`.\n\nNotice that both key must already exist otherwise the command will fail.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tscreaterule.\n\nExample:\n\n* `$ts-\u003ecreateRule('source', 'destination', new AggregationRule(AggregationRule::AVG, 10000)`, will populate the\n`destination` key by averaging the samples contained in `source` over 10 second buckets. \n\n### `deleteRule`\n\n`TimeSeries::deleteRule(string $sourceKey, string $destKey): void`\n\nDeletes an existing aggregation rule.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsdeleterule.\n\n### `range`\n\n`TimeSeries::range(string $key, ?DateTimeInterface $from = null, ?DateTimeInterface $to = null, ?int $count = null, ?AggregationRule $rule = null, bool $reverse = false): Sample[]`\n\nRetrieves samples from a key. It's possible to limit the query in a given time frame (passing `$from` and `$to`),\nto limit the retrieved amount of samples (passing `$count`), and also to pre-aggregate the results using a `$rule`.\n\nThe flag `$reverse` will return the results in reverse time order.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsrange.\n\n### `multiRange` and `multiRangeWithLabels`\n\n`TimeSeries::multiRange(Filter $filter, ?DateTimeInterface $from = null, ?DateTimeInterface $to = null, ?int $count = null, ?AggregationRule $rule = null, bool $reverse = false): Sample[]`\n\n`TimeSeries::multiRangeWithLabels(Filter $filter, ?DateTimeInterface $from = null, ?DateTimeInterface $to = null, ?int $count = null, ?AggregationRule $rule = null, bool $reverse = false): SampleWithLabels[]`\n\nSimilar to `range`, but instead of querying by key, queries for a specific set of labels specified in `$filter`.\n\n`multiRangeWithLabels` will return an array of `SampleWithLabels` instead of simple `Sample`s.\n\nThe flag `$reverse` will return the results in reverse time order.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsmrange.\n\n### `getLastSample`\n\n`TimeSeries::getLastSample(string $key): Sample`\n\nGets the last sample for a key.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsget.\n\n### `getLastSamples`\n\n`TimeSeries::getLastSamples(Filter $filter): Sample[]`\n\nGets the last sample for a set of keys matching a given `$filter`.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsmget.\n\n### `info`\n\n`TimeSeries::info(string $key): Metadata`\n\nGets useful metadata for a given key.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsinfo.\n\n### `getKeysByFilter`\n\n`getKeysByFilter(Filter $filter): string[]`\n\nRetrieves the list of keys matching a given `$filter`.\n\nSee https://oss.redislabs.com/redistimeseries/commands/#tsqueryindex.\n\n## Advanced connection parameters\n\nYou can manipulate your `RedisConnectionParams` using the following methods:\n\n* `RedisConnectionParams::setPersistentConnection(bool $persistentConnection)` enable/disable a persistent connection\n* `RedisConnectionParams::setTimeout(int $timeout)` connection timeout in seconds\n* `RedisConnectionParams::setRetryInterval(int $retryInterval)` retry interval in seconds\n* `RedisConnectionParams::setReadTimeout(float $readTimeout)` read timeout in seconds\n\n## Building Filters\n\nA `Filter` is composed of multiple filtering operations. At least one equality operation must be provided (in the \nconstructor). Adding filtering operations can be chained using the method `add`.\n\nExamples:\n\n* `$f = (new Filter('label1', 'value1'))-\u003eadd('label2', Filter::OP_EXISTS);` filters items which have label1 = value1\nand have label2.\n* `$f = (new Filter('label1', 'value1'))-\u003eadd('label2', Filter::OP_IN, ['a', 'b', 'c']);` filters items which have\nlabel1 = value1 and where label2 is one of 'a', 'b' or 'c'.\n\n## Local testing\nFor local testing you can use the provided `docker-compose.yml` file, which will create a PHP container (with the redis\nextension pre-installed), and a redis container (with Redis Time Series included).\n\n## Contributors\nThanks [Mrkisha](https://github.com/Mrkisha) for the precious contributions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalicao%2Fphpredistimeseries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalicao%2Fphpredistimeseries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalicao%2Fphpredistimeseries/lists"}