async def connect(self):
self.redis = await aioredis.create_redis( 'redis://localhost',encoding='utf-8')
async def disconnect(self, close_code):
await self.redis.close()
REDIS_PRO_POOL = redis.ConnectionPool(host='localhost', port=6379, db=3)
class TestConsumer(AsyncWebsocketConsumer):
@sync_to_async
def test(self, value):
r = redis.Redis(connection_pool=settings.REDIS_PRO_POOL)
r.set("TEST", value)
print(r.get(value))
r.close()
async def connect(self):
await self.test("hello")
....