Forums / Developer / Use some cache in a custom fetch function
Jerome Despatis
Thursday 01 April 2010 10:08:57 am
Hi,
I've done a function fetch in my extension, It may be called several times in a page, and I now the result is always the same, how can I make my fetch use a cache ?
I could use $GLOBALS of course and store in a specific key (hoping not to override an existing key), but I'm sure there's a better way :)
Any idea is welcome
Bertrand Dunogier
Thursday 01 April 2010 12:06:11 pm
Well, honestly, if you just need to cache temporary data for one run, you should use a global... just centralize the read/write code for these globals so that you can easily refactor it, and prefix your global names with your initials or company acronym... just like we do with eZ. There should be no conflicts this way (not more than with classes, at least :p).
If you want to implement more persistent caching, here are the options I would consider:
Bertrand Dunogier eZ Systems Engineering, Lyon http://twitter.com/bdunogier http://gplus.to/BertrandDunogier
Thursday 01 April 2010 12:34:28 pm
Ok thanks
I already use it for plain file cache, I've seen memory cache also, let's test that...