Tag:pos how much time amount sts otherwise object highlight poll
# __author__ = ' STEVEN ' Import redis,time# connection Pool polls = Redis. ConnectionPool (host= ' 192.168.43.22 ', port= ' 6379 ') # Select connect from the connection pool R = Redis. Redis (connection_pool=polls) # #hset () operation, set one Key-value value at a time, if key exists, then uodate otherwise add # r.hset (name= ' info ', key= ' name ', Value= ' GWB ') # R.hset (name= ' info ', key= ' age ', value= ') ' #根据对象名和要查找字段的键得到对应的值 # Print (R.hget (name= ' info ', key= ' name ') # #hmset () operation, set multiple Key-value values at once to an object # R.hmset (name= ' info1 ', mapping={' name ': ' Lisi ', ' age ': +}) #hlen () Find how many objects are in the table # Print (R.hlen (name= ' info1 ')) #hmget () Get the field value by the table name and the specified field name # Print (R.hmget (name= ' Info1 ', keys= (' name ', ' age ')) #hval () Gets the name of all fields in the specified table name # print (r.hvals (name= ' Info1 ')) # Hkeys () operation implementation to isolate all keys, return # print (R.hkeys (name= ' info1 ')) to the list #hdel () Deletes the record for the specified field in the specified table # R.hdel (' info1 ', ' name ') # print (R.hvals (name= ' info1 ')) #hexists () View the field names specified in the specified table as incorrect # print (R.hexists ( Name= ' Info1 ', key= ' sex ') # r.hset (name= ' info1 ', key= ' id ', value=1) #hincrby () Sets the growth step for the specified field of the specified table name, returns the growth number of # print ( R.hvals (name= ' info1 '), R.hincrby (name= ' info1 ', key= ' id ', amount=2)) #hscan () finds all records in the specified table that meet the pattern criteria, returns the # R.hset in tuples (name= ' Info1 ', key= ' sex ', value= ' man ') # print (R.hkeys (name= ' Info1 ')) # Print (R.hscan (name= ' info1 ', cursor=0,match= ' *e* ')) #hscan_iter () finds all key values that specify a table name that conforms to the specified pattern and returns an iterator to it = R.hscan_iter (name= ' info1 ', match= ' *e* ') print (it.__next__ ()) Print (it . __next__ ())
Python operation of Redis hash operation