What happens with modules and themes when I rebuild the cache? Just for learning, this document explains me in a "ballpark" way how cache rebuild works, but I want to know more about "Updates the system with latest information about extensions (modules and themes)."

What happens with modules and themes when I rebuild the cache?
To create a page Drupal needs to make several database queries. This can slow down websites with a lot of traffic. To make websites faster Drupal stores web pages in a cache.

Before Drupal 8, the common mantra was drush cc all (i.e. drush clear-cache). Now, in Drupal 8, it's drush cache-rebuild OR drush cr.

Caching is widespread in Drupal and creates many interdependencies. Improperly or incomplete cache flushing operations can cause the site to fatal error. In order to guarantee that old data is properly flushed and the site stays up and running,  drush cache-rebuild both rebuilds or re-bootstraps the Drupal site in    addition to clearing the cache

In-short, Drush's cache-rebuild command does the following:


Clears the APC cache
Bootstraps Drupal
Calls drupal_rebuild()
Clears the Drush cache (to maintain consistency with Drupal 7's drush cache-clear command)


If you would like to dig more into this check out https://github.com/drush-ops/drush/blob/659f67712adab143a2c921f9f23828782e414e8d/commands/core/cache.drush.inc#L263 at the end of the file, look at function drush_cache_rebuild().

Thanks!