You are here

function entitycache_entity_update in Entity cache 7

Implements hook_entity_update().

File

./entitycache.module, line 98
Allows for caching of core entities.

Code

function entitycache_entity_update($entity, $type) {

  // It is possible for other _update() hooks to load an entity before it has
  // been properly saved, for example file_field_update(). This may cause
  // an incomplete entity to be cached, since hooks which run after the one
  // loading the entity do not have a chance to run. Therefore ensure the cache
  // is always cleared when updating entities.
  // Since hook_entity_insert() runs last, there's a good chance of acting
  // after other modules are finished loading.
  $info = entity_get_info($type);
  list($id) = entity_extract_ids($type, $entity);
  if (!empty($info['entity cache']) && empty($entity->migrate)) {
    cache_clear_all($id, 'cache_entity_' . $type);
  }
}