In Amazon Elasticache - Memcached, if the server is restarted, the Memcached clears the cache since there is no persistence for Elasticache Memcached.
This answer includes a manual "Cache-warming" step, however, there's no built-in mechanism for cache warming in Amazon ElastiCache for Memcached specifically.
Here is an example of how to use cache warming with Memcached:
In the above example, we initialize a new Memcached client instance and preload it with some frequently accessed data using the set() method. After restarting Memcached, we can then access the cached data using the get() method. By preloading the cache with frequently accessed data, we minimize the impact of the cache being empty after a restart.
It's also worth noting that some Memcached clients support automatic cache reloading when a cache miss occurs. This means that if you try to access data that is not currently cached, the client will automatically reload the data from the backend data store and add it to the cache. This can help reduce the impact of restarting Memcached on your application's cache.