Last active
May 22, 2019 07:26
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aioredis | |
class MyRedis(object): | |
_redis = None | |
@classmethod | |
async def redis(cls): | |
if not cls._redis: | |
cls._redis = await aioredis.create_redis('redis://localhost') | |
return cls._redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tornado.web import RequestHandler | |
from redis-singleton import MyRedis | |
class MyHandler(RequestHandler): | |
async def get(self): | |
id = self.request.arguments.get('id', None) | |
self.redis = await MyRedis.redis() | |
await self.redis.set(id, json.dumps({"status": 0})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment