Last active
May 22, 2019 07:26
-
-
Save ityoung/cf6f561da66a32a09744ecf17bfb9d82 to your computer and use it in GitHub Desktop.
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