Entity cache only supports core entities. However, for contrib, implementing entitycache support doesn't seem too hard.

1) Adding this code to the controller object looks like it should work for tying into the caching system:

  public function resetCache(array $ids = NULL) {
    if (module_exists('entitycache')) {
      EntityCacheControllerHelper::resetEntityCache($this, $ids);
    }
    parent::resetCache($ids);
  }

  public function load($ids = array(), $conditions = array()) {
    if (module_exists('entitycache')) {
      return EntityCacheControllerHelper::entityCacheLoad($this, $ids, $conditions);
    }
    else {
      return parent::load($this, $ids, $conditions);
    }
  }

2) We have to add the cache bin to hook_schema() and a hook_update to create the cache bin. We should create the table even if entity cache isn't enabled, even though the table isn't used, otherwise management will be a pain in the keester.

3) We need to implement hook_flush_caches to add the cache bin.

4) There might be more I haven't seen in a quick examination of the module.

Comments

merlinofchaos’s picture

Oh yes.

4) We need to set the 'entity cache' and 'field cache' keys in the entity_info appropriately if entity cache is enabled.

dave reid’s picture

Sounds pretty straight forward. Did you want to take this on Earl or should I get started on it?

merlinofchaos’s picture

Well there's a bug in my above code, where parent::load() shouldn't have a $this. :)

merlinofchaos’s picture

I don't know if/when I'll get to it. If you want to do it, go for it. If it hasn't been done in, you know, a while (Determined based on my completely unscientific method of "when I realize it hasn't been done yet and want to go do it") then I'll do it then. :)

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new8.45 KB

Patch ready for review.

dave reid’s picture

StatusFileSize
new8.44 KB

Erg, didn't make patch after I had saved an edit.

dave reid’s picture

I was looking into adding some db_table_exists() wrappers in case the user hasn't run update.php yet and hits flush_caches or any entity load/saving. But I think I'm just going to commit as is. We shouldn't hand-hold for people that can't update when there is clearly updates to run. It doesn't really 'break' anything, it just has warnings about the cache table not existing.

dave reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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