The snippet shows how to clear Drupal 10 cache programmatically. You can do that for all of the cache or one by one using the ID of the cache that you want to clear.
Source code viewer
\Drupal::cache()->invalidateAll(); // One by one. \Drupal::cache('cache.backend.mysql')->deleteAll(); // clear MySQL cache \Drupal::cache('cache.page')->deleteAll(); // clear page cache \Drupal::cache('cache.entity')->deleteAll(); // clear entity cacheProgramming Language: PHP