Set (name, value, Ex=none, Px=none, Nx=false, xx=false) setting value, ex, expiration Time (seconds) px, expiration Time (milliseconds) NX is ture, only name does not exist, current operation is performed, XX is true, Only name exists, current operation is executed
SETNX (name, value) sets the value, only if the name does not exist, the operation is performed
Setex (name, value, time) sets the value, in seconds, for expiration
Psetex (name, Time_ms, value) sets the value, Time_ms indicates the expiration time (in milliseconds)
Mset (*args, **kwargs) bulk set values
Get (name) get value
Mget (keys, *args) bulk acquisition
Getset (name, value) sets the new value and gets the old value
GetRange (key, start, end) Gets the subsequence, start represents the start position (in bytes), and end indicates the ending position (in bytes)
SETRANGE (name, offset, value) modifies the contents of the string, starting from the specified string index and replacing it backwards
Setbit (name, offset, value) modifies the string, offset represents the byte index, and value can only be set to 1 or 0
Getbit (name, offset) Gets the value of a bit in the binary representation of the value corresponding to the name
Bitcount (Key, Start=none, End=none) Gets the value of name corresponding to the number of 1 in the binary representation, start is the starting position, end is the ending position
Bitop (operation, dest, keys) gets multiple values and takes a bitwise operation to save the final result to the new name corresponding to the value, Operation,and (and), or (or), not (non), XOR (XOR) dest, New name,key, to find the name
strlen (name) returns the byte length of name
INCR (self, name, amount=1) increment the value corresponding to name, create Name=amount (integer) When name does not exist
Incrbyfloat (self, name, amount=1.0) increment the value corresponding to name, create Name=amount (floating-point number) when name does not exist
DECR (self, name, amount=1) decrement the value of name, and create Name=amount (integer) When name does not exist
Append (key, value) appends content after the value corresponding to name
pool = redis.ConnectionPool(host=‘127.0.0.1‘,port=6379)r = redis.Redis(connection_pool=pool)r.set(‘k1‘,‘v1‘,ex=None,px=None,nx=False,xx=False)r.setnx(‘k2‘,‘k2‘)r.setex(‘k3‘,‘v3‘,time=1)r.psetex(‘k4‘,time_ms=1000,value=‘v4‘)r.mset({‘k5‘:‘v5‘,‘k6‘:‘v6‘})print(r.get(‘k1‘))print(r.mget([‘k2‘,‘k3‘,‘k4‘]))print(r.getset(‘k5‘,‘V5‘))print(r.getrange(‘k1‘,start=0,end=1))r.setrange(‘k2‘,offset=0,value=1)r.setbit(‘k3‘,offset=1,value=1)print(r.getbit(‘k4‘,offset=1))print(r.bitcount(‘k5‘,start=0,end=-1))r.bitop(‘AND‘,‘k6‘,‘k1‘,‘k2‘)print(r.strlen(‘k1‘))r.incr(‘k2‘, amount=1)r.incrbyfloat( ‘k2‘, amount=1.0)r.decr(‘k3‘,amount=1)r.append(‘k4‘, ‘after‘)