Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.
/ gredis Public archive

gRedis is an asynchronous client library of Redis written with Tornado coroutine.

Notifications You must be signed in to change notification settings

coldnight/gredis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gredis

gRedis is an asynchronous client library of Redis written with Tornado coroutine.

gRedis is standing on the shoulders of giants:

Installation

pip install gredis

OR

easy_install gredis

OR

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

Usage

from tornado import gen
from tornado import web
from gredis.client import AsyncRedis

client = AsyncRedis("ip.or.host", 6379)

class DemoHandler(web.RequestHandler):

    @gen.coroutine
    def get(self):
        ret = yield client.incr("key")
        redis = client.to_blocking_client()
        ret2 = redis.incr("key")
        self.write(str(ret + ret2))

Pub/Sub

from tornado import gen
from tornado import web
from gredis.client import AsyncRedis

client = AsyncRedis("ip.or.host", 6379)

class PubSubHandler(web.RequestHandler):

    @gen.coroutine
    def get(self):
        pubsub = client.pubsub()
        channel = "test"
        yield pubsub.subscribe(channel)
        response = yield pubsub.get_message(True)
        assert response["type"] == "subscribe"
        response = yield pubsub.get_message(True)
        assert response["type"] == "message"
        self.write(response['data'])

    @gen.coroutine
    def post(self):
        yield client.publish(channel, "test")

Not Implementation

  • pipeline

About

gRedis is an asynchronous client library of Redis written with Tornado coroutine.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages