Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement Azure Managed Redis data operations, including caching, expiration, and invalidation

A worked example

Yes or no

A developer is adding caching to a Python application. The application uses the redis (redis-py) library and a client named r that is already connected to an Azure Managed Redis instance. The developer is reviewing the client methods that the application will use for caching and expiration.

For each of the following statements, select Yes if the statement is true. Otherwise, select No.

StatementYesNo
Calling r.setex() stores a string value and sets its expiration time in a single atomic operation.

SETEX sets a string value and its expiration time together, atomically.

Correct
In the call r.psetex('temp:data', 5000, 'temporary_value'), the key expires after 5,000 seconds.

PSETEX takes its expiration in milliseconds, so this key expires after 5,000 milliseconds (5 seconds), not 5,000 seconds.

Correct
When r.exists() is called with three key names, it returns True if all three keys exist.

With several keys, r.exists() returns the number of keys that exist. For example, if two of three keys exist, the call returns 2, not a single True/False value.

Correct
Why

SETEX writes a string value and its time to live in one atomic step. PSETEX works the same way but takes the expiration in milliseconds, so 5000 means five seconds. When EXISTS is given several keys, it returns a count of the keys that are present. It does not return a Boolean that requires all of them to exist.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free