Skip to main content

You should use Entity cache

An article from ComputerMinds - Building with Drupal in the UK since 2005
23rd Jul 2013

Steven Jones

Senior Developer
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

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.

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.