Created
March 6, 2012 21:35
-
-
Save k0d/1989086 to your computer and use it in GitHub Desktop.
CherryPy Redis Test
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
#!/usr/bin/env python | |
#encoding:UTF-8 | |
import cherrypy | |
import redis | |
class Root(object): | |
redis = redis.StrictRedis(host='localhost', port=6379, db=0) | |
def counter(self): | |
value = self.redis.incr('counter'); | |
return "REDIS INCR - counter:%s" % value | |
counter.exposed = True | |
def set(self, key, value): | |
self.redis.set(key, value); | |
return "REDIS SET - %s:%s" % (key, value) | |
set.exposed = True | |
def get(self, key): | |
value = self.redis.get(key) | |
return "REDIS GET - %s:%s" % (key, value) | |
get.exposed = True | |
root = Root() | |
cherrypy.server.socket_host = '0.0.0.0'; | |
cherrypy.quickstart(Root()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment