I have a little function that deletes specific entity references directly from database. Because of fact that it bypass the whole entity_load / entity_save system it flushes cache of all entities it affects by itself.
The weird thing is that it doesn't work. The references, while not present in the database, still show up on node view / edit pages.
$affected_users = db_select('field_data_fmu_users_firm', 'su') ->fields('su', array('entity_id')) ->condition('fmu_users_firm_target_id', $user_id, '=') ->execute()->fetchCol(); db_delete('field_data_fmu_users_firm') ->condition('fmu_users_firm_target_id', $user_id, '=') ->execute(); entity_get_controller('user')->resetCache($affected_users);
No special caching module is enabled on the site.