Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am trying to figure out how to cache custom entities with Entitycache module:
created cache table for own entity: cache_entity_carroza_user
created own controller, extent EntityCacheDefaultEntityController, implemented EntityAPIControllerInterface:
<?php
class CarrozaEntityController extends EntityCacheDefaultEntityController implements EntityAPIControllerInterface {
...
}
?>
implemented hook_entity_info, specified entity controller:
<?php
$return = array(
'carroza_user' => array(
'label' => t('Carroza User'),
'controller class' => 'CarrozaUserEntityController',
....
if(module_exists('entitycache')) {
$return['carroza_user']['field cache'] = FALSE;
$return['carroza_user']['entity cache'] = TRUE;
}
?>
created CarrozaUserEntityController:
<?php
class CarrozaUserEntityController extends CarrozaEntityController {
public function __construct($entityType) {
parent::__construct($entityType);
}
public function resetCache(array $ids = NULL) {
EntityCacheControllerHelper::resetEntityCache($this, $ids);
parent::resetCache($ids);
}
public function load($ids = array(), $conditions = array()) {
return EntityCacheControllerHelper::entityCacheLoad($this, $ids, $conditions);
}
public function create(array $values = array()) {
$values += array(
'carroza_uid' => '',
'is_new' => TRUE,
...
);
$carroza_user = parent::create($values);
return $carroza_user;
}
public function save($carroza_user, DatabaseTransaction $transaction = NULL) {
return parent::save($carroza_user, $transaction);
}
}
?>
I'm doing everything Entitycache documentation says, but can't see any records in cache_entity_carroza_user table. Am I missing something else?