0
0
Redisquery~10 mins

Connection pooling in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Redis connection pool.

Redis
pool = redis.ConnectionPool(host='localhost', port=6379, [1]=5)
Drag options to blanks, or click blank then click option'
Adb
Btimeout
Cmax_connections
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'timeout' instead of 'max_connections' will not limit pool size.
Setting 'db' or 'password' does not control connection pooling.
2fill in blank
medium

Complete the code to get a Redis client using the connection pool.

Redis
client = redis.Redis(connection_pool=[1])
Drag options to blanks, or click blank then click option'
Apool
Bconnection
Cclient
Dredis
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a client or redis module instead of the pool causes errors.
Using an undefined variable name.
3fill in blank
hard

Fix the error in the code to properly release a connection back to the pool.

Redis
with client.[1]() as conn:
    conn.set('key', 'value')
Drag options to blanks, or click blank then click option'
Apipeline
Bclient
Cget_connection
Dconnection
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get_connection' is not a valid method on the client.
Using 'connection' or 'client' does not manage connection context.
4fill in blank
hard

Fill both blanks to create a connection pool with a timeout and get a client.

Redis
pool = redis.ConnectionPool(host='localhost', port=6379, [1]=10)
client = redis.Redis(connection_pool=[2])
Drag options to blanks, or click blank then click option'
Asocket_connect_timeout
Bpool
Cmax_connections
Dsocket_timeout
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'max_connections' with timeout parameters.
Passing a wrong variable to connection_pool.
5fill in blank
hard

Fill all three blanks to create a connection pool, get a client, and set a key with a timeout.

Redis
pool = redis.ConnectionPool(host='localhost', port=6379, [1]=20)
client = redis.Redis(connection_pool=[2])
client.set('session', 'active', [3]=300)
Drag options to blanks, or click blank then click option'
Amax_connections
Bpool
Cex
Dtimeout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'timeout' instead of 'ex' for expiration.
Passing wrong variable names to connection_pool.