import redis
import sys
class DataBase:
def __init__(self):
self.host="redis31.myhost"
self.port=15008
def write(self,keystr,valuestr):
try:
r=redis.StrictRedis(host=self.host,port=self.port)
r.set(keystr,valuestr)
except Exception as e:
print e
def read(self,keystr):
try:
r=redis.StrictRedis(host=self.host,port=self.port)
value=r.get(keystr)
print "read redis key:",keystr
return value
except Exception as e:
print e
return ""
if __name__=="__main__":
db=DataBase()
if len(sys.argv) <= 2:
print 'useridkey or token is null ,work is end...'
else:
userid=sys.argv[1]
token=sys.argv[2]
key=userid
value="userinfoJson"
print key
db.write(key,value)
values=db.read(key)
print values
import sys
class DataBase:
def __init__(self):
self.host="redis31.myhost"
self.port=15008
def write(self,keystr,valuestr):
try:
r=redis.StrictRedis(host=self.host,port=self.port)
r.set(keystr,valuestr)
except Exception as e:
print e
def read(self,keystr):
try:
r=redis.StrictRedis(host=self.host,port=self.port)
value=r.get(keystr)
print "read redis key:",keystr
return value
except Exception as e:
print e
return ""
if __name__=="__main__":
db=DataBase()
if len(sys.argv) <= 2:
print 'useridkey or token is null ,work is end...'
else:
userid=sys.argv[1]
token=sys.argv[2]
key=userid
value="userinfoJson"
print key
db.write(key,value)
values=db.read(key)
print values