February 2018
Intermediate to advanced
382 pages
11h 33m
English
To show how to set expiration on keys, we store the IDs of five restaurants that are closest to the user's current location in a Redis list. As the user's location may change frequently, we should set a timeout on this Redis list. After the timeout has expired, we will fetch the restaurant list again using the current location:
127.0.0.1:6379> LPUSH "closest_restaurant_ids"109 200 233 543 222 (integer) 5
127.0.0.1:6379> EXPIRE "closest_restaurant_ids" 300 (integer) 1
127.0.0.1:6379> TTL "closest_restaurant_ids" ...
Read now
Unlock full access