Skip to main content
Tweeted twitter.com/#!/StackDrupal/status/429200731544227841
added 5 characters in body
Source Link
xurshid29
  • 2.5k
  • 15
  • 13

I am trying to figure out how to cache custom entities with Entitycache module. As I know Entitycache module doesn't support custom entites created with Entity API, that's why I'm doing like this:

created cache table for own entity: cache_entity_carroza_user

created own controller, extent EntityCacheDefaultEntityController, implemented EntityAPIControllerInterface:

class CarrozaEntityController extends EntityCacheDefaultEntityController implements EntityAPIControllerInterface {
  ...
}

implemented hook_entity_info, specified entity controller:

$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:

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?

I am trying to figure out how to cache custom entities with Entitycache module. As I know Entitycache module doesn't support custom entites created with Entity API, that's why I'm doing like this:

created cache table for own entity: cache_entity_carroza_user

created own controller, extent EntityCacheDefaultEntityController, implemented EntityAPIControllerInterface:

class CarrozaEntityController extends EntityCacheDefaultEntityController implements EntityAPIControllerInterface {
  ...
}

implemented hook_entity_info, specified entity controller:

$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:

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?

I am trying to figure out how to cache custom entities with Entitycache module. As I know Entitycache module doesn't support custom entites created with Entity API, that's why I'm doing like this:

created cache table for own entity: cache_entity_carroza_user

created own controller, extent EntityCacheDefaultEntityController, implemented EntityAPIControllerInterface:

class CarrozaEntityController extends EntityCacheDefaultEntityController implements EntityAPIControllerInterface {
  ...
}

implemented hook_entity_info, specified entity controller:

$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:

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?

Source Link
xurshid29
  • 2.5k
  • 15
  • 13

Proper way to cache custom entities with Entitycache?

I am trying to figure out how to cache custom entities with Entitycache module. As I know Entitycache module doesn't support custom entites created with Entity API, that's why I'm doing like this:

created cache table for own entity: cache_entity_carroza_user

created own controller, extent EntityCacheDefaultEntityController, implemented EntityAPIControllerInterface:

class CarrozaEntityController extends EntityCacheDefaultEntityController implements EntityAPIControllerInterface {
  ...
}

implemented hook_entity_info, specified entity controller:

$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:

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?