当前位置:网站首页>PY3 redis general call
PY3 redis general call
2022-07-19 04:37:00 【Little wooden man】
Record a python Generic call class
# -*- coding: utf-8 -*-
import redis
import json
from config import OFFICIAL_APIS
class Redis_read_write:
@staticmethod
def get_redis():
""" obtain Redis The connection of """
r = redis.Redis(host=OFFICIAL_APIS['redis_ip'], port=OFFICIAL_APIS['redis_port'], username=None, password=None,
db=0)
return r
# set_data(key_name, access_token, ex=7100)
@staticmethod
def set_data(name, value, **kwargs):
# Store data redis cache
r = Redis_read_write.get_redis()
value = json.dumps(value)
r.set(name, value, **kwargs)
# get_data(key_name)
@staticmethod
def get_data(name):
# Take out key by name Value
r = Redis_read_write.get_redis()
value = r.get(name)
if value:
value = json.loads(value)
return value
边栏推荐
- Golang reverse slice code example
- 复旦微FMQL(国产Zynq) 【IAR裸机开发之PS】——非字节对齐访问
- Autojs learning - map finding data generation
- CAD video course recommendation station B
- Swift 【Class】【struct】
- 2022/7/16 周赛
- ‘ionic‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
- 【TA-霜狼_may-《百人计划》】美术2.1 DCC工具链与引擎工具链
- MySQL中的删除:delete、drop、Truncate三者的区别
- STM32——定时器系列(二)通用定时器
猜你喜欢

基于STM32的SG90舵机实验含代码(HAL库)
![[Unity] Input.gettouch[index]的index](/img/9d/ec0e4c9e6b1bb25976357469fe037f.png)
[Unity] Input.gettouch[index]的index

Sphinx遇到的问题

DNS原理及解析过程

百度地图技术概述,及基本API与WebApi的应用开发

iptables防止nmap扫描以及binlog详解

数据分析报告这样写,才算真正读懂了数据

MySql 一行变多行(根据特定符号分割)

Overview of Baidu map technology, and application development of basic API and webapi

Data types of basic knowledge of C language
随机推荐
Gin framework principle
T + 0 to t + 1! The quick redemption amount is reduced to 10000! Another bank adjusted the rules for the application and redemption of cash wealth management products
ospf综合实验
[ruoyi Vue plus] learning notes 30 - redisson (VI) bounded blocking queue (redisson source code + Lua script)
Virtual lab basic experiment tutorial -7 Polarization (3)
模拟服务器进行请求
PowerDesigner显示Comment注释
Real time Bi (IV) low cost data quasi real time processing idea
Gin框架原理
[Unity] 交互之双击
tf.AUTO_REUSE的作用
AutoJs学习-2048小游戏自动化
Xcode11 add a boot page (the launch images source option is missing after the upgrade)
深度学习中的标量、向量、矩阵和张量的区别
成熟的线程要懂得拒绝
使用Everything清理垃圾文件
【TA-霜狼_may-《百人计划》】基础渲染光照介绍(一)
EasyExcel简单使用
mysql中的视图、触发器和存储过程
Architecture and application of secure multiparty computing