• 190707Python-Redis


    一、Redis的简单使用

    • Redis操作模式
    # Author:Li Dongfei
    import redis
    r = redis.Redis(host='192.168.56.7', port=6379)
    r.set('foo', 'bar')
    print(r.get('foo'))
    
    • Redis连接池
    # Author:Li Dongfei
    import redis
    pool = redis.ConnectionPool(host='192.168.56.7', port=6379)
    r = redis.Redis(connection_pool=pool)
    r.set('foo', 'bar')
    print(r.get('foo'))
    

    二、string

    • set(name, value, ex=None, px=None, nx=False, xx=False)
    • setnx(name, value)
    • setex(name, value, time)
    • psetex(name, time_ms, value)
    • mset(*args, **kwargs)
    • get(name)
    • mget(keys, *args)
    • getset(name, value)
    • getrange(key, start, end)
    • setrange(name, offset, value)
    • setbit(name, offset, value)
    • bitcount(key, start=None, end=None)
    • bitop(operation, dest, *keys)
    • strlen(name)
    • incr(self, name, amount=1)
    • incrbyfloat(self, name, amount=1.0)
    • decr(self, name, amount=1)
    • append(key, value)

    三、hash

    • hset(name, key, value)
    • hmset(name, mapping)
    • hget(name,key)
    • hmget(name, keys, *args)
    • hgetall(name)
    • hlen(name)
    • hkeys(name)
    • hvals(name)
    • hexists(name, key)
    • hdel(name,*keys)
    • hincrby(name, key, amount=1)
    • hincrbyfloat(name, key, amount=1.0)
    • hscan(name, cursor=0, match=None, count=None)
    • hscan_iter(name, match=None, count=None)

    四、list

    • lpush(name,values)
    • lpushx(name,value)
    • llen(name)
    • linsert(name, where, refvalue, value))
    • r.lset(name, index, value)
    • r.lrem(name, value, num)
    • lpop(name)
    • lindex(name, index)
    • lrange(name, start, end)
    • ltrim(name, start, end)
    • rpoplpush(src, dst)
    • blpop(keys, timeout)
    • brpoplpush(src, dst, timeout=0)

    五、set

    • sadd(name,values)
    • scard(name)
    • sdiff(keys, *args)
    • sdiffstore(dest, keys, *args)
    • sinter(keys, *args)
    • sinterstore(dest, keys, *args)
    • sismember(name, value)
    • smembers(name)
    • smove(src, dst, value)
    • spop(name)
    • srandmember(name, numbers)
    • srem(name, values)
    • sunion(keys, *args)
    • sunionstore(dest,keys, *args)
    • sscan(name, cursor=0, match=None, count=None)
    • sscan_iter(name, match=None, count=None)
  • 相关阅读:
    Oracle存储过程小记DUAL
    线程私有数据(TSD)
    Unix 五种基本I/O模型的区别
    Redis系列(0)应用场景
    linux ubuntu引导 win7
    Redis系列(一)启动流程分析
    c++ 内存管理小结
    设计模式Facade模式应用场景
    学会理财不做穷人
    jquery 注册验证例子
  • 原文地址:https://www.cnblogs.com/L-dongf/p/11145714.html
Copyright © 2020-2023  润新知