I have enabled the module, after creating the cache_entity_custom_entity db table, and updated my entity info to have:

  'entity cache' => module_exists('entitycache'),
  'field cache' => module_exists('entitycache'),

I use entity_create and the controller save function:

  public function save($entity, DatabaseTransaction $transaction = NULL) {
    parent::save($entity, $transaction);
  }

From my controller, an extension of EntityAPIController.

Entities are created and saved, but I do not see any cache entries get created. I've tried both from drush (I have a script importer/updater for custom entity data) and also a CRUD frontend like Nodes have, but still don't get a cache entry. Is there something I am missing?

Comments

Anonymous’s picture

Did you ad//extend the entity info controller class to EntityCacheDefaultEntityController ?

paulbeaney’s picture

Hi kevinquillen ,

Did you work out how to do this in the end? If you did, would you mind sharing the details as I'm trying to get some cacheing on my custom entity too.

Regards,

- Paul

kevinquillen’s picture

I was unsuccessful. I kept getting different CRUD related fatal errors from EntityAPI from EntityCacheDefaultEntityController.

paulbeaney’s picture

Hi kevinquillen,

You might want to try again in case things have changed. I just added the save() function to my controller class, and added the entity info, and I've got cache entries appearing in the cache table, so I assume all is working ok! My entity is based on Entity API rather than built from scratch, in case that makes a difference to you.

Regards,

- Paul

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

I would check out the commit to Fieldable Panels Panes which has optional integration with Entity cache. Also make sure you are testing with entitycache 7.x-1.x-dev, not the stable release from 2011.

Phizes’s picture

  'entity cache' => module_exists('entitycache'),
  'field cache' => module_exists('entitycache'),

If entitycache is present, you are enabling both the field and entity caches, while if entitycache is not available, you are disabling both of them. I'm not sure if this is causing your actual issue. I think your code here should be as such:

  'entity cache' => module_exists('entitycache'),
  'field cache' => !module_exists('entitycache'),
Phizes’s picture

[Duplicate of #6]
Apologies for the spam.

Phizes’s picture

[Duplicate of #6]

acbramley’s picture

@Dave Reid, thanks for the link that commit is a great way of showing how to add entitycache to your entities. It seems strange to reference a commit and not chuck this into documentation somewhere though.

acbramley’s picture

Also this implementation doesn't seem to work with EntityAPI entities (i.e controller class extends EntityAPIController)

EDIT:It's something to do with the load function, I'm getting the "Recoverable fatal error: Argument 1 passed to my_entity_page_title() must be an instance of MyEntity, instance of stdClass given in my_entity_page_title()". When I comment out the

return EntityCacheControllerHelper::entityCacheLoad($this, $ids, $conditions);

and just allow it to use parent::load it works fine. I assume EntityAPI implements it's own integration with entitycache, wonder if you need the resetCache() override, would anyone know?

markusa’s picture

Issue summary: View changes

If you are building a custom entity, and you declare your own controller, if you extend EntityAPIController, it has support for entitycache.

All you need to do at is create the cache table as specified in the commit or like so:

/**
 * Implementation of hook_install
 */ 
function YOUR_MODULE_NAME_install() {
  $schema = drupal_get_schema_unprocessed('system', 'cache');
  $schema['description'] = "Cache table used to store YOUR ENTITY entity records.";

  db_create_table('cache_entity_YOUR_ENTITY_NAME', $schema);
}

then add this to your hook_entity_info() implementation:

  'entity cache' => module_exists('entitycache'),
  'field cache' => !module_exists('entitycache'),

enable entitycache module
boom its going