Component for working with Time Series data structure in Redis – downsampling, compaction, min, max, avg, sum, range, deviations and much more.
- TPBRedisTimeSeries.TS_CREATE
- TPBRedisTimeSeries.TS_MADD
- TPBRedisTimeSeries.TS_INFO
- …
Prerequirements
- In order for this component to work you have to obtain, install and run the respective Redis software and its licenses. We do not provide any Redis software.
- PBClient for RedisTimeSeries requires PBClient for Redis as the core component. It should be installed to provide a connection with the Redis server.
OS compatibility
7 SP2 x64 |
8 x64 |
8.1 x64 |
10 x64 |
11 x64 |
RAD Studio compatibility
10 Seattle |
10.1 Berlin |
10.2 Tokyo |
10.3 Rio |
10.4 Sydney |
11 Alexandria |
1 user
3 users
5 users
10 users
Site license
Free components in a bundle
Buy a bundle now and enjoy all new component releases for free during the update period. |
Keep track of multiple versions
You will get access to all older versions and a detailed changelog. |
Free new features
Get all new component features for free during the free update period. |
Install once use forever
Our products are not time limited. |
Source code promise
In case our component will become obsolete and we no longer support it, we will provide you its source code. So you don’t have to worry about a replacement. |
References:
> QSG code example provided with the installer
> RedisTimeSeries native commands
After installation, a group PyBridge will appear in the Tool Palette of Delphi, where you can find a new component TPBRedisTimeSeries. PBClient for RedisTimeSeries requires PBClient for Redis as the core component. It should be installed to provide a connection with the Redis server.
New component TPBRedisTimeSeries could be found in the Tool Palette under PyBridge group
Place TPBRedisClient onto the form and set up its main properties:
- AutoOpen – set True for automatic connection to Redis
- RedisServer – setup host, password and port number to access Redis
The default Redis database ID that TPBRedisClient is going to work with is 0, but you may specify a different database ID. To do so – create the OnConnect event handler procedure of the PBRedisClient object. Keep in mind that the trial version does not support the selection of databases.
1 2 3 4 |
procedure TForm1.PBRedisClient1Connect; begin PBRedisClient1.Select(0); // PBRedisClient. Selecting a database number in redis. end; |
Place TPBRedisTimeSeries onto the form and set up its main properties:
- RedisClient – select the PBRedisClient object which should provide a connection with the Redis server
Now PBClient for RedisTimeSeries is ready to be used. To demonstrate how it works, let’s create a simple application that could append serial data from CSV file to RedisTimeSeries and then retrieve it back. Add the corresponding buttons and Memo to your form:
In the provided example we’re using a real data set with EUR/USD rates for the period from 2021/09/01 00:00 to 2021/09/07 23:59. The data set is stored in the CSV format under “.\..\data\EUR_USD_202109010000-202109072359.csv“. TS_MADD command accepts TStringArray object as the parameter. Each string of the array in the object should have the following structure: “key;timestamp;value”. Let’s prepare such an object in the ButtonClick event handler procedure of the ‘Data’ button.
1 |
// see implementation in the example
|
In the ButtonClick event handler procedure of the ‘TS_MADD’ button, we’re using several functions of PBRedisClient and PBRedisTimeSeries.
1 2 3 4 5 |
if PBRedisClient1.EXISTS(key) = False then begin // PBRedisClient. Checking that a key exists. PBRedisTimeSeries1.TS_CREATE(key, -1, enGLOBAL, 0, dpLAST); // PBRedisTimeSeries. Creation of a new time series. end; jres:=PBRedisTimeSeries1.TS_MADD(ts.ToStringArray); // PBRedisTimeSeries. Appending new samples to one or more time series. jres:=PBRedisTimeSeries1.TS_INFO(key); // PBRedisTimeSeries. Getting information and statistics about time series. |
First, we have to TS_CREATE a new time series using a key name and a set of parameters. It returns result as a JSON object. But before we must check if a time series with such a key name already exists using EXISTS command of PBRedisClient. It returns a Boolean result. Then, we’re using TS_MADD to append data from the TStringArray object, which we prepared earlier, to the Redis time series. It returns result as a JSON object. Finally, we can get information and statistics about the time series by using TS_INFO command. It returns result as a JSON object.
In the ButtonClick event handler procedure of the ‘TS_RANGE’ button we’re querying a range of the time series using TS_RANGE command of PBRedisTimeSeries component.
1 2 3 4 5 6 7 |
procedure TForm1.TS_RANGEClick(Sender: TObject); var jres: string; begin jres:=PBRedisTimeSeries1.TS_RANGE(key, ts_start, ts_finish, [], [], 50); // PBRedisTimeSeries. Querying key values in the time range. Memo1.Lines.Append(jres.Replace('],[', '],' + #13#10 + '[').Replace('Result":[', 'Result":[' + #13#10)); end; |
This example demonstrates how easy it is to develop Delphi applications relying on time series with a help of PBClient for RedisTimeSeries. Now you can also enjoy the full power of RedisTimeSeries in your applications!