I did some additional testing using python 3.6 + redistimeseries-0.4.
The trimming mechanism really works and the series is cleared. I probably misunderstood the documentation, or it is not correct.
retentionTime - Maximum age for samples compared to last event time (in milliseconds)
I figured I should pass milliseconds in the retentionTime parameter.
Therefore, when I tried to save 6 seconds of data for the experiment, I multiplied 6 * 1000 and passed it to the "retentionTime" parameter.
And I watched the series for much longer than 6 seconds. Then it reduced the value passed to the "retentionTime" parameter to 6 and then the series really began to store 6 seconds of data, deleting older values.
Here is the code i use to test data insertion (6 seconds for single key):
from time import time as now_ts
from time import sleep
from redistimeseries.client import Client
from random import choice
# redis connectionredis_host = 'localhost'
redis_port = 6379
rts = Client(host = redis_host, port = redis_port)
def add_with_retention(count, retention): # timestamp 10 digit
num = 0
while num < count:
rand_float_value = choice(range(0, 1000)) / 100
timestamp = int(now_ts())
rts.add('test_key_1', timestamp, rand_float_value, retention_msecs=retention, labels={'type':'analog'})
num += 1
sleep(1)
if __name__ == "__main__":
rts.flushall()
add_with_retention(count=20, retention=6) # 6 seconds of data
I would still like clarification on what should be passed in the retentionTime parameter (seconds or milliseconds).
пятница, 18 октября 2019 г., 12:43:44 UTC+5 пользователь Alexander Korochkin написал: