当前位置:网站首页>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
边栏推荐
- [daily question] sword finger offer II 041 Average value of sliding window
- Swift 【Class】【struct】
- As a result, all system modifications of the company will be upgraded
- MySql 一行变多行(根据特定符号分割)
- 策略模式代替if-else
- ospf防环
- AutoJs学习-实现极乐净土
- [Unity] 交互之双击
- 删除文件 unable to find or create trash dirctory
- README. MD add directory
猜你喜欢

深度学习中的标量、向量、矩阵和张量的区别

ospf防环

HCR Huichen is walking on the north slope, a giant beast swimming into digital marketing services

Touchid and faceid~1

MySQL中的删除:delete、drop、Truncate三者的区别

OSPF routing control, anti ring related knowledge

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

Virtual lab basic experiment tutorial -7 Polarization (3)

Optimization and configuration of OSPF

Delete the file unable to find or create trash directory
随机推荐
【每日一题】剑指 Offer II 041. 滑动窗口的平均值
DNS原理及解析过程
MySQL中的删除:delete、drop、Truncate三者的区别
Cabasicanimation pause \ enterprise action
使用kaggle跑李宏毅机器学习作业
Overview of Baidu map technology, and application development of basic API and webapi
VB.NET插件开发- 提取文件
对称加密与非对称加密
OSPF basic optimization
Time frequency diagram classification challenge of intelligent hardware voice control 2.0 (ideas and results, currently top5)
OpenLDAP自定义schema
Virtual lab basic experiment tutorial -7 Polarization (3)
[TA frost wolf _may - "hundred people plan"] art 2.1 DCC tool chain and engine tool chain
Autojs learning-2048 small game automation
TiDB学习笔记【初阶】
HCR慧辰北坡而行,一只游入数字营销服务的巨兽
对于每一个 Provider 实例都会维护多个连接
Typeorm MySQL upsert operation
The author of surging issued the pressure test results
MySQL one line to many lines (split according to specific symbols)