Exemplo n.º 1
0
 async def hscan(self,
                 str_key,
                 cursor=0,
                 match=None,
                 count=None,
                 mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.hscan(str_key, cursor, match, count)
Exemplo n.º 2
0
 async def zrange(self,
                  str_key,
                  begin,
                  end,
                  withscore=False,
                  score_cast_func=float,
                  mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.zrange(str_key, begin, end, withscore, score_cast_func)
Exemplo n.º 3
0
 async def set(self,
               str_key,
               value,
               ex=None,
               px=None,
               nx=False,
               xx=False,
               mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.set(str_key, value, ex, px, nx, xx)
Exemplo n.º 4
0
from common import Db, Redis
from route import route
from tornado.gen import coroutine
from tornado.concurrent import Future


def hello_timer():
    # print("hello timer")
    pass


if __name__ == "__main__":
    settings = {
        'debug': True,
        "cookie_secret": "__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
    }
    app = tornado.web.Application(route, **settings)

    # app = make_app()
    app.listen(8000)
    Db.instance()       # 初始化db连接池
    Redis.init()    # 初始化redis连接池
    iol = tornado.ioloop.IOLoop.current()
    # 定时器 毫秒为单位
    tornado.ioloop.PeriodicCallback(
        hello_timer, 1000
    ).start()
    print('app start on', 8000)
    iol.start()

Exemplo n.º 5
0
 async def sadd(self, str_key, field, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.sadd(str_key, field)
Exemplo n.º 6
0
 async def zincry(self, str_key, field, add, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.zincrby(str_key, field, add)
Exemplo n.º 7
0
 async def zset(self, str_key, mod='redis', *argvs, **kwargs):
     conn = Redis.conn(str_key, mod)
     return conn.zadd(str_key, *argvs, **kwargs)
Exemplo n.º 8
0
 async def expire(self, str_key, expire, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.expire(str_key, expire)
Exemplo n.º 9
0
 async def get(self, str_key, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.get(str_key)
Exemplo n.º 10
0
 async def hmget(self, str_key, fields, mapping, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.hmget(str_key, fields, mapping)
Exemplo n.º 11
0
 async def hset(self, str_key, filed, value, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.hset(str_key, filed, value)
Exemplo n.º 12
0
 async def hgetall(self, str_key, mod='reids'):
     conn = Redis.conn(str_key, mod)
     return conn.hgetall(str_key)
Exemplo n.º 13
0
 async def hget(self, str_key, filed, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.hget(str_key, filed)
Exemplo n.º 14
0
 async def srem(self, str_key, *values, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.srem(str_key, *values)
Exemplo n.º 15
0
 async def smembers(self, str_key, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.smembers(str_key)
Exemplo n.º 16
0
 async def sismember(self, str_key, field, mod='redis'):
     conn = Redis.conn(str_key, mod)
     return conn.sismember(str_key, field)