Reference connection:
https://www.cnblogs.com/wupeiqi/articles/5132791.html
What redis that?
redis is a software that helps developers on a machine memory to operate .
You can be doing?
Memory for the operating software.
--- do persist
AOF: Redis sucked execution of each write command recorded in a separate log file AOF file execute the command again when Redis restart when to recover the data.
ROB: RDB persistence is the process of writing data to a file.
- the equivalent of a large dictionary
- single-threaded process
type of data
1. String
k1: "This is a sad story."
2. List
k2:[1,2,3,4,5,6,7,8]
3. collection
Q3: {1,2,3,4,5,6}
4. Dictionary
k4:{ name:123, age:666 }
5. ordered set
k5:{('alex',60),('eva-j'80),('rt',70)}
operating
redis-py provides two classes for implementing Redis Redis and StrictRedis commands StrictRedis for implementing most of the official order,
And use of official syntax and commands , Redis is StrictRedis subclass, for backward compatibility with older versions of redis-py.
Ordinary redis
Import redis # 1. Create a connection redis R & lt redis.Redis = (Host = ' 127.0.0.1 ' , Port = 6379 ) # 2. only set a value into redis r.set ( ' foo ' , ' Bar ' ) # 3 to the value redis Print (r.get ( ' foo ' ))
Connection pooling redis
Why use connection pooling?
redis-py using a connection pool to manage all the connections to a redis server , avoid each establishment, connection release overhead . By default, each instance of Redis will maintain its own connection pool.
Can establish a direct connection pool, then Redis as parameters, this can be achieved Redis multiple instances share a connection pool.
# Connection pool
Import redis
# 1. Create a connection pool redis
the pool redis.ConnectionPool = (Host = ' 127.0.0.1 ' , Port = 6379 )
# 2. Each instance Redis will maintain its own connection pool.
redis.Redis = R & lt (= connection_pool the pool)
# 3. Add the values Redis
r.set ( ' foo ' , ' Bar ' )
# 4. values
Print (r.get ( ' foo ' ))