import redis
import configparser
import os
config = configparser.ConfigParser()
conf_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
class RedisTool:
def __init__(self, redis_db):
self.redis_host = '127.0.0.1'
self.redis_port = '6379'
self.redisConnect = redis.StrictRedis(self.redis_host, self.redis_port, redis_db, decode_responses=True)
def hexists(self, name, key):
return self.redisConnect.hexists(name, key)
def hget(self, name, key):
return self.redisConnect.hget(name, key)
def getset(self, name, value):
return self.redisConnect.getset(name, value)
def hdel(self, name, *keys):
return self.redisConnect.hdel(name, *keys)
def delete(self, name):
return self.redisConnect.delete(name)
def hgetall(self, name):
return self.redisConnect.hgetall(name)
def hkeys(self, name):
return self.redisConnect.hkeys(name)
def hlen(self, name):
return self.redisConnect.hlen(name)
def hset(self, name, key, value):
return self.redisConnect.hset(name, key, value)
def hmset(self,name,mapping):
return self.redisConnect.hmset(name, mapping)
def hmget(self,name,key):
return self.redisConnect.hmget(name, key)
def setex(self, name, time, value):
return self.redisConnect.setex(name, time, value)
def get(self, name):
return self.redisConnect.get(name)
def exists(self, name):
return self.redisConnect.exists(name)
def set(self, name, value, ex=None):
return self.redisConnect.set(name, value, ex=ex)
def expire(self, name, time):
return self.redisConnect.expire(name, time)
def pexpire(self, name, time):
return self.redisConnect.pexpire(name, time)
def setnx(self, name, value):
return self.redisConnect.setnx(name, value)
Redis的增删改
最新推荐文章于 2024-05-30 01:33:53 发布