1 Star 0 Fork 0

hpchao / ReportIP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
BaseRedis.py 772 Bytes
一键复制 编辑 原始数据 按行查看 历史
hpchao 提交于 2017-11-18 17:36 . 初始化
import redis
import myConfig
def creatRedis(remotAddr=myConfig.remotAddr,port=myConfig.port,pwd=myConfig.pwd):
'''
创建远程连接对象
:param remotAddr: 远程地址
:param port: 远程端口
:param pwd: 连接密码
:return:连接对象
'''
r = redis.Redis(host=remotAddr, port=port, password=pwd)
return r
#获取key
def get_RemoteKey(keyname,r=creatRedis()):
'''
根据键获取远程对象的值
:param keyname: 键名
:return: 值
'''
n = r.get(keyname)
r.connection_pool.disconnect()
return n
def set_RemoteKey(key,value,r=creatRedis()):
'''
设置远程数据库中的键值对
:param key: 键
:param value: 值
:return: 执行结果
'''
n = r.set(key, value)
r.connection_pool.disconnect()
return n
Python
1
https://gitee.com/hpch/ReportIP.git
git@gitee.com:hpch/ReportIP.git
hpch
ReportIP
ReportIP
master

搜索帮助