Modules should have the possibility to react on a cache reset.
Example use case is the title module which does a field synchronisation.
It caches on which entity the sync is done to prevent unnecessary processing.
Unfortunately the module has no way to detect if a resync is necessary due an entitycache reset.

Attached patch adds the same code as in EntityCacheControllerHelper::entityCacheAttachLoad() for EntityCacheControllerHelper::resetEntityCache

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Status: Needs review » Needs work

Since entitycache isn't just able to implement hook_entity_update() and hook_entity_delete() due to inconsistencies in the core entities, it probably makes sense to provide this hook to save other modules having to figure out the same thing.

However, please add documentation to entitycache.api.php for the new hooks (I realise there is no docs in there for hook_entitycache_load() yet, will add those soon or happily commit a patch).

Also while I'm not sold on Drupal 7 hook groupings yet, not all sites will have entitycache module enabled - so it might be worth adding a group here so that code can be loaded only when needed (especially since cache resets only happen on requests doing CUD operations).

das-peter’s picture

The api doc is up to date now.

das-peter’s picture

Status: Needs work » Needs review
catch’s picture

Status: Needs review » Needs work

Thanks for this, needs tweaks for coding style though.

- line break is missing between function summary and @param
- for some reason (I don't know why) we don't state argument types in the @param line.

Otherwise looks great.

das-peter’s picture

*grml* I always forget the thing with the param types - I'm used to add these because the Eclipse PDT autcomplete function ;).
^^ Same no type rule applies to returns too, right?

catch’s picture

Status: Needs work » Fixed

Thanks. No type rule applies to return as well yeah.

Committed!

Automatically closed -- issue fixed for 2 weeks with no activity.