This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Discussions » How to implement caching for extensions

Tuesday 29 November 2011 12:29:22 pm - 4 replies

» Read full blog post


While working on an extension that uses the YouTube API, I decided to add functionality to cache the XML retreived. I worked out how to do this on basis of the files 'kernel\classes\datatypes\ezuser\ezuser.php (search for 'getUserCacheByUserId') and the comments at the top of file kernel\private\interfaces\ezclusterfilehandlerinterface.php. In case you would want to do something similair, or if you have same feedback, here is an explanation of how I implemented caching for my extension.

Wednesday 30 November 2011 7:27:06 pm

This is GREAT! I'm going to implement this for a custom extension and it would be of great help for me.

Thanks for sharing this!

Thursday 01 December 2011 10:34:15 pm

You can also use the very very good component Cache from Apache Zeta Component.

And then define your own strategies for the cache handling.

Friday 02 December 2011 6:49:49 am

Hello Sebastiaan,

Thank you for your blog post, It was a good read, I enjoyed it.


We implemented something kindof similar for use within eZ Publish templates.

bcfetchxml is simply a template operator which simply provides remote xml file loading, optional caching and debugging.

It's not perfect but it does allow you to disable the caching depending on the call and it reuses the site.ini:[RSSSettings] CacheTime setting and cache directory for it's cache files.

As I look at this extension again I wonder if another expiry time parameter might make this a bit more flexible to use in more than one kind of usage (and make more sense) than simply a cache on/off parameter (depending on your site/cache/template cache/cache block use cases).

We found this helpful as it helped us reach a few goals so we shared it as a reference for the community.

Here is a simple example

fetchxml( $url (url, required), true() (cache, optional (defaults to true)), false() (debug, optional (defaults to false)) )


I hope this helps ...




Friday 02 December 2011 5:06:48 pm

You can also use the very very good component Cache from Apache Zeta Component.

And then define your own strategies for the cache handling.

Unfortunately, ezcCache is not cluster aware... BUT, you might take advantage of what we implemented for REST as of 4.5. There is indeed an ezcCache handler designed to work with the cluster. However, it is mainly designed to work with REST (cache will be located in var/<siteaccess>/cache/rest, and the scope will be rest-cluster-cache.

Be also aware that objects you want to cache needs to implement ezcBaseExportable interface (with __set_state() method).

A good usage example can be found here :

ezcCache cluster handlers are here and there


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from