-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from thefab/docs
Add Getting Started section
- Loading branch information
Showing
5 changed files
with
227 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import tornado | ||
import tornadis | ||
import logging | ||
logging.basicConfig(level=logging.CRITICAL) | ||
|
||
loop = tornado.ioloop.IOLoop.instance() | ||
client = tornadis.Client() | ||
|
||
|
||
def ping_callback(ping_future): | ||
exception = ping_future.exception() | ||
if exception is None: | ||
print("Command result: %s" % ping_future.result()) | ||
else: | ||
print("Error: %s" % exception) | ||
loop.stop() | ||
|
||
|
||
def connection_callback(connect_future): | ||
exception = connect_future.exception() | ||
if exception is None: | ||
print("We are connected to Redis") | ||
ping_future = client.call("PING") | ||
loop.add_future(ping_future, ping_callback) | ||
else: | ||
print("Error: %s" % exception) | ||
|
||
|
||
connect_future = client.connect() | ||
loop.add_future(connect_future, connection_callback) | ||
loop.start() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import tornado | ||
import tornadis | ||
import logging | ||
logging.basicConfig(level=logging.CRITICAL) | ||
|
||
loop = tornado.ioloop.IOLoop.instance() | ||
|
||
|
||
def connection_callback(future): | ||
exception = future.exception() | ||
if exception is None: | ||
print("We are connected to Redis") | ||
else: | ||
print("Error: %s" % exception) | ||
loop.stop() | ||
|
||
|
||
client = tornadis.Client() | ||
future = client.connect() | ||
loop.add_future(future, connection_callback) | ||
loop.start() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import tornado | ||
import tornadis | ||
import logging | ||
logging.basicConfig(level=logging.CRITICAL) | ||
|
||
loop = tornado.ioloop.IOLoop.instance() | ||
client = tornadis.Client() | ||
|
||
|
||
def callback(future): | ||
exception = future.exception() | ||
if exception is not None: | ||
raise exception | ||
loop.stop() | ||
|
||
|
||
@tornado.gen.coroutine | ||
def talk_to_redis(): | ||
yield client.connect() | ||
result = yield client.call("PING") | ||
print "Result: %s" % result | ||
|
||
|
||
connect_future = client.connect() | ||
main_future = talk_to_redis() | ||
loop.add_future(main_future, callback) | ||
loop.start() |
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