How to invalidate cache when a config entity is added/deleted? In a MenuLinkContent entity I've a list_string field populated with a $key =&gt; $value array of a custom config entity. When I add or delete a config entity the values in my field are not updated until I rebuild the cache.

I think I should set a cache tag, but I can not figure out where I should add the tag and which tag should I use.

Edit: The array is created in a static method on my entity class.

public static function getConfigList() {

  $entities = SvgIcon::loadMultiple();
  $config_list = array();

  /** @var SvgIconInterface $entity */
  foreach ($entities as $entity) {
    $config_list[$entity-&gt;get('id')] = $entity-&gt;get('label');
  }

  return $config_list;
}


The field is defined via hook_entity_base_field_info().

function svg_icon_menu_link_entity_base_field_info(EntityTypeInterface $entity_type) {

  $fields = array();

  if ( $entity_type-&gt;get('id') !== 'menu_link_content' ) {
    return $fields;
  }

  $fields['svg'] = BaseFieldDefinition::create('list_string')
    -&gt;setLabel('SVG sprite')
    -&gt;setDescription('Select the SVG sprite file.')
    -&gt;setSettings(array(
      'allowed_values' =&gt; SvgIcon::getConfigList()
    ))
    -&gt;setDisplayOptions('form', array(
      'type' =&gt; 'select',
      'weight' =&gt; 0,
      'settings' =&gt; array(
        'display_label' =&gt; TRUE
      )
    ));

  return $fields;
}
List fields support an allowed_values_callback setting, if you use that, then you don't need to worry about cache invalidation.

See https://api.drupal.org/api/drupal/core!modules!options!options.api.php/function/callback_allowed_values_function/8.2.x and