This commit is contained in:
yhydev
2025-06-14 13:15:50 +00:00
commit 85a2a49261
7 changed files with 289 additions and 0 deletions

19
redis_service.py Normal file
View File

@@ -0,0 +1,19 @@
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"}))