def testPool(self): redis = Redis(port=port) client = RedisTimeSeries(conn=redis, port=666) name = 'test' client.create(name) self.assertEqual(None, client.get(name)) client.add(name, 2, 3) self.assertEqual(2, client.get(name)[0]) info = client.info(name) self.assertEqual(1, info.total_samples)
pool = redis.ConnectionPool(host=redis_host, port=redis_port) r = redis.Redis(connection_pool=pool) try: r.xadd("mystream", {'event_type': 'startup', 'user': '******'}) r.xgroup_create("mystream", "consumerGroup", '$') except: print("group already exists") while True: msgs = r.xreadgroup("consumerGroup", "consumerName", streams={"mystream": '>'}, count=10, block=1000, noack=False) for msg in msgs: for m in msg[1]: evnt = m[1]['event_type'] try: rts.info(evnt) except: rts.create(evnt, retentionSecs=60, labels={'event_type': evnt}) rts.create(evnt + "_minute", retentionSecs=0, labels={'event_type': evnt}) rts.createrule(evnt, evnt + "_minute", 'count', 60) rts.incrby(evnt, 1)