Python operation of Redis hash operation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.