1 Star 0 Fork 0

PeterPZhang / python常用函数demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
连接redis取值.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
PeterPZhang 提交于 2019-07-30 17:14 . redis数据库连接取值
# -*- coding: utf-8 -*-
"""
__author__ = 'peter'
__mtime__ = '2019-07-30'
# Follow the master,become a master.
             ┏┓      ┏┓
            ┏┛┻━━━━━━━┛┻┓
            ┃    ☃    ┃
            ┃  ┳┛  ┗┳  ┃
            ┃     ┻    ┃
            ┗━┓      ┏━┛
              ┃      ┗━━━━┓
              ┃ 神兽保佑   ┣┓
              ┃ 永无BUG! ┏┛
              ┗┓┓┏━━━┳┓┏━━━┛
               ┃┫┫  ┃┫┫
               ┗┻┛  ┗┻┛
"""
import redis
def get_uid_token(user_type, user_id):
"""
# 连接redis方法
:param user_id:
:param user_type:
:return:
"""
global redis_server
if user_type == 'f': # 前台app用户
db = 2
elif user_type == 'b': # 后台商铺用户
db = 4
elif user_type == 'a': # 主后台管理用户
db = 7
else:
return None
redis_server = redis.Redis(host=conf.rd_host, port=conf.rd_port, password=conf.rd_pwd, db=db)
if redis_server.get(user_id) is not None: # 判断是否有uid(登陆是否过期)
token = redis_server.get(user_id).decode() # 未过期将uid解码
else:
token = None
return token
Python
1
https://gitee.com/PeterPZ/python_common_function_demo.git
git@gitee.com:PeterPZ/python_common_function_demo.git
PeterPZ
python_common_function_demo
python常用函数demo
master

搜索帮助