Package: redis-timeseries
Redis TimeseriesTime series API built on top of Redis that can be used to store and query
time series statistics. Multiple time granularities can be used to keep
track of different time intervals.Free software: MIT licenseDocumentation:https://redis-timeseries.readthedocs.io.InstallTo install Redis Timeseries, run this command in your terminal:$pipinstallredis_timeseriesUsageTo initialize the TimeSeries class, you must pass a Redis client to
access the database. You may also override the base key for the time series.>>> import redis
>>> client = redis.StrictRedis()
>>> ts = TimeSeries(client, base_key='my_timeseries')To customize the granularities, make sure each granularity has attlanddurationin seconds. You can use the helper functions for
easier definitions.>>> my_granularities = {
...     '1minute': {'ttl': hours(1), 'duration': minutes(1)},
...     '1hour': {'ttl': days(7), 'duration': hours(1)}
... }
>>> ts = TimeSeries(client, granularities=my_granularities).record_hit()accepts a key and an optional timestamp and increment
count. It will record the data in all defined granularities.>>> ts.record_hit('event:123')
>>> ts.record_hit('event:123', datetime(2017, 1, 1, 13, 5))
>>> ts.record_hit('event:123', count=5).record_hit()will automatically execute whenexecute=True. If you
setexecute=False, you can chain the commands into a single redis
pipeline. You must then execute the pipeline with.execute().>>> ts.record_hit('event:123', execute=False)
>>> ts.record_hit('enter:123', execute=False)
>>> ts.record_hit('exit:123', execute=False)
>>> ts.execute().get_hits()will query the database for the latest data in the
selected granularity. If you want to query the last 3 minutes, you
would query the1minutegranularity with a count of 3. This will return
a list of tuples(bucket, count)where the bucket is the rounded timestamp.>>> ts.get_hits('event:123', '1minute', 3)
[(datetime(2017, 1, 1, 13, 5), 1), (datetime(2017, 1, 1, 13, 6), 0), (datetime(2017, 1, 1, 13, 7), 3)].get_total_hits()will query the database and return only a sum of all
the buckets in the query.>>> ts.get_total_hits('event:123', '1minute', 3)
4.scan_keys()will return a list of keys that could exist in the
selected range. You can pass a search string to limit the keys returned.
The search string should always have a*to define the wildcard.>>> ts.scan_keys('1minute', 10, 'event:*')
['event:123', 'event:456']FeaturesMultiple granularity trackingRedis pipeline chainingKey scannerEasy to integrate with charting packagesCan choose either integer or float countingDate bucketing with timezone supportCreditsAlgorithm copied fromtonyskn/node-redis-timeseriesThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.8 (2017-07-25)Fix bug in _round_time() method0.1.7 (2017-07-25)Fix bug in _round_time() method0.1.6 (2017-07-25)Add timezone so day buckets will start at midnight in the correct timezone0.1.5 (2017-07-18)Update default granularities0.1.4 (2017-07-12)Add float value capabilitiesAdd increase() and decrease() methodsMove get_hits() -> get_buckets() and get_total_hits() -> get_total()0.1.3 (2017-03-30)Remove six packageClean up source file0.1.2 (2017-03-30)Make Python 3 compatibleFix tox to make PyPy work0.1.1 (2017-03-30)Minor project file updates0.1.0 (2017-03-30)First release on PyPI.