20 lines
562 B
Python
20 lines
562 B
Python
import aioredis
|
|
redis = aioredis.from_url(
|
|
"redis://:redispasswd..QAQ@127.0.0.1:6379/0"
|
|
)
|
|
|
|
async def push(stream, data):
|
|
if isinstance(data, list):
|
|
async with redis.pipeline() as pipe:
|
|
for i in data:
|
|
await pipe.xadd(stream, i, maxlen=200000)
|
|
await pipe.execute()
|
|
return
|
|
async with redis as conn:
|
|
await conn.xadd(stream, data, maxlen=200000)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import asyncio
|
|
asyncio.run(push_agg_trade_data({"s": "BTCUSDT", "T": 1680895800000, "p": "10000"}))
|