gredis是用tornado coroutine编写的redis异步客户端库。

gredis的Python项目详细描述


格雷迪斯

gredis是用Tornado协程编写的redis异步客户端库。

格雷迪斯站在巨人的肩膀上:

安装

pip install gredis

easy_install gredis

git clone https://github.com/coldnight/gredis
cd gredis
python setup.py install

用法

fromtornadoimportgenfromtornadoimportwebfromgredis.clientimportAsyncRedisclient=AsyncRedis("ip.or.host",6379)classDemoHandler(web.RequestHandler):@gen.coroutinedefget(self):ret=yieldclient.incr("key")redis=client.to_blocking_client()ret2=redis.incr("key")self.write(str(ret+ret2))

发布/订阅

fromtornadoimportgenfromtornadoimportwebfromgredis.clientimportAsyncRedisclient=AsyncRedis("ip.or.host",6379)classPubSubHandler(web.RequestHandler):@gen.coroutinedefget(self):pubsub=client.pubsub()channel="test"yieldpubsub.subscribe(channel)response=yieldpubsub.get_message(True)assertresponse["type"]=="subscribe"response=yieldpubsub.get_message(True)assertresponse["type"]=="message"self.write(response['data'])@gen.coroutinedefpost(self):yieldclient.publish(channel,"test")

不执行

  • 管道

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在不扩展小程序的情况下使用小程序方法?   Java/包含点的排序数组   java如何在EJB项目中创建会话?   java JavaFX我切换了场景,但我不能再回来了   环境变量为java设置类路径时%classpath%的含义是什么   java如何使用Serenity BDD管理浏览器选项卡?   java如何创建一个。gwt中的war文件在eclipse中使用maven?   java使用java程序更新HTML文件   Java、SQLite、向数据库插入数据   java无法在RPi上安装JDK 16   在不进行反射的情况下调用动态java方法   如何在Ubuntu上安装Eclipse和Java SDK?   JavaSSHMySQL连接   在内存和性能方面,用Java每秒打印格式化日期+时间的最有效方法是什么?   java如何匹配映射返回类型的键和值?   java JUnit测试挂起在clientSocket上。接受()?   jbossweb中的java系统属性引用。服务器启动时未解析xml   java如何在set操作中使用arrayUnion   java 安卓。看法充气异常:二进制XML文件行#22