Redis的增删改

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值