You've just started development on an application that will make use of the ElastiCache service.
You need to ensure that objects are cached but not kept inadvertently for a long time.
Which of the following strategy would you employ for the cache service?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A.
The AWS Documentation mentions the following.
Lazy loading allows for stale data but won't fail with empty nodes.
Write through ensures that data is always fresh but may fail with empty nodes and may populate the cache with superfluous data.
By adding a time to live (TTL) value to each write, we can enjoy the advantages of each strategy and largely avoid cluttering up the cache with superfluous data.
Option B is incorrect because this is a caching strategy that loads data into the cache only when necessary.
Option C is incorrect because this is a caching strategy that adds data or updates data in the cache whenever data is written to the database.
Option D is incorrect because there is no such caching strategy.
For more information on Caching strategies, please refer to the below URL-
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Strategies.htmlTo ensure that objects are cached but not kept inadvertently for a long time, you can use Time-To-Live (TTL) expiration. Therefore, the correct answer is A. Adding TTL.
TTL is a setting that specifies the amount of time for which an object can remain in the cache before it is automatically evicted. This is a useful feature that prevents your cache from becoming stale and keeps the most frequently accessed data in the cache. When an object's TTL expires, it is evicted from the cache and must be reloaded from the original data source.
Lazy Loading, Write Through, and Read Through are caching strategies, but they do not address the requirement of ensuring that objects are cached but not kept inadvertently for a long time. Let's briefly explain each of them:
Lazy Loading: This is a technique that loads data into the cache only when it is needed. It is useful for improving performance by reducing the amount of data that needs to be loaded into the cache upfront. However, it does not address the requirement of ensuring that objects are not kept in the cache for too long.
Write Through: This caching strategy involves writing data to the cache and the data source simultaneously. This ensures that the data in the cache is always consistent with the data in the data source. However, it does not address the requirement of ensuring that objects are not kept in the cache for too long.
Read Through: This caching strategy involves loading data from the data source into the cache on demand. This ensures that the data in the cache is always consistent with the data in the data source. However, it does not address the requirement of ensuring that objects are not kept in the cache for too long.
In summary, the correct answer is A. Adding TTL, which will help you ensure that objects are cached but not kept inadvertently for a long time.