Skip to main content

You should use Entity cache

23rd Jul 2013

Steven Jones

Senior Developer

If you have a Drupal 7 site, then you should be using the Entity cache module, here's why:

Lots and lots of things in Drupal are 'entities', such as the content, the users, the taxonomy terms and if you're using contrib modules like Field collection or ECK, then those are entities too.

Most of the time you have some fields on those entities, then every time Drupal needs to load one up, it'll also have to read the data for each field from these tables. Once you start having lots of entities, and potentially field collections on those entities, you can end up with lots of database queries very quickly!

Entity cache can help with the mountain of database queries by storing cached copies of the fully loaded entities in Drupal's cache system.

We've seen this reduce the number of database queries on a page by several hundred!

There are no ill effects to using Entity cached entities if all your code is using Drupal's APIs and not manipulating the data for an entity in the database directly, essentially you can just enable it and forget about it, simple!

We've worked with the module maintainers of ECK to get add Entity cache support and are working with the Field collection maintainers to get Entity cache support there too.

If you have a module that provides entities then you have a small amount of work to do allow Entity cache to support them, but it's easy, and you can see examples in those issues above.