init
This commit is contained in:
19
redis_service.py
Normal file
19
redis_service.py
Normal 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"}))
|
||||
Reference in New Issue
Block a user