Installing a third-party module Redis
Import Redis
I. Connect to the database, and change the operation and additions.
1. Connecting data
(1). host Required Server IP
(2). Port number Default thing 6379, can not fill in, if changed to other port number, to fill in
(3). Password is not filled by default, if you set a password, to fill in
(4). DB Required value is an integer that represents the first few databases
2. Adding and deleting change operation string type
(Redis is a key-value pair)
2.1 Add/Modify Key-value value
You can set the expiration time as follows:
2.2 Querying data
(1). Gets the value of value by the key value of the Get method, gets the binary
Converts the acquired value to a string by using the Decode () method
The correct result:
(2). When key does not exist, get non-existent key, do not convert to string, value return value does not error, is none
Converted to a string to get the nonexistent key, the error is as follows:
2.3 Delete the specified key, when the deleted key does not exist, also does not error
2.4 Other methods
Python Operations Redis--------------database additions and deletions