So cache_id is most of the time necessary in modules and doing a check for a cached template before doing heavy processing might also be very important performance wise.
--
campertoday.nl, Module development, Dutch Zikula Community
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- craigh responded to »Using PageUtil::addVar() to load script code« 03:29 PM
- michiel responded to »password problem« 10:01 AM
- mazdev responded to »Hide "Register new account" and change template to 3 col« 07:50 AM
- mesteele101 created topic »Zikula 1.3.3 - Site Search 1.5.2 - Unable to turn off plug-ins« 07:48 AM
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
please explain Caching
-
- Rank: Developer
- Registered: Aug 23, 2003
- Last visit: May 31, 2010
- Posts: 1428
-
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1967
I am very pleased with this discussion so far. It has really helped us all think about what is supposed to happen with caching.
unfortunately, I've seen too many 'I'm not sure' and 'I'll have to check' type comments to feel like we have closed the book on this issue. Obviously, somebody needs to truly understand Zikula caching and give a definitive word. Some testing may be in order here to confirm the behavior we expect. -
- Rank: Software Foundation
- Registered: Jul 21, 2001
- Last visit: May 31, 2010
- Posts: 624
It's all about how you implement caching. Ultimately you need to determine a cache id. You dont need to focus on overall uniqueness in the system because Zikula factors in template name, theme, language, module name etc. You just need to make a unique identifier for the data. For a single object, the ID, or for paginated lists, the start and range, and for random data, lists of IDs. It would all depend on the complexity of your module.
Remember, caching goes deeper than trying to avoid SQL calls, actually, the controller can be the wrong place for that. The database layer is where we should be concentrating on caching (and we do). DBUtil does it automatically, Doctrine does it automatically now and Doctrine 2 has a clever UoW pattern which caches even if you haven't got backend caching.
Looking at it another way, if pages are unique by their get request, that is where we should be looking at for caching, and not implementing anything in the module code, but at framework level. If caching is enabled and we get a request for /news/view/1 then that should be the caching key and it can be framework level. There would be no reason to have any controller specific cache handling in this case. It's all about how you implement the caching - there are always two ways to skin a cat.
Something to look at later for sure.
Drak
--
Zikula Lead Developer
Board Member of the Zikula Foundation
Follow me on twitter.com/zikuladrak -
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1967
OK, here's another pertinent question....
what is the difference between render caching and theme caching? and why (in Theme settings) can you exclude certain modules from theme caching, but not from render caching? -
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1967
craigh
Some testing may be in order here to confirm the behavior we expect.
So, in order for me to understand it, I needed to use it and abuse it and figure it out. I've begun to do so by writing some code to demonstrate the various ways of usage. If you want to check it out (please do!) you can download my HelloWorld module for Zikula 1.3
to answer a few of the questions raised earlier:
1) cacheid is not required to be set unless one template is used to display multiple contents (like article.tpl renders a bunch of different articles or something). In these cases, you have to generate and assign some unique id. Thanasis' point about referencing the function is probably unneeded unless you are using the identical template for both functions (possible but unlikely).
2) compileid is probably not worth playing with. Compiling basically prepares a PHP version of the Smarty template (open one and look at it). So it is just a 'native PHP' version of Smarty code. Since you probably don't need a bunch of different versions of this, you can allow smarty/view to handle this. At the moment, I'm not sure I can conceive of a situation where you would want multiple unique compiled templates.
3) cacheid and compileid are both autogenerated and are related. for example, you will end up with two compile files something like:
alwayscached-7e4cdcd4bcc2a5fc3f11b48766f968c3.tpl.inc
alwayscached-7e4cdcd4bcc2a5fc3f11b48766f968c3.tpl.php
and a cached file like:
d41d8cd98f00b204e9800998ecf8427e-alwayscached-7e4cdcd4bcc2a5fc3f11b48766f968c3.tpl
notice that the long hexidecimal compileid is also in the cacheid.
I have more to learn, but I thought I would share what I have with you so far. try out my demo :)
by the way - this doesn't really address the render vs. theme issue. I think I know the answer there, but was hoping someone else could shed some light... -
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1967
just implemented another demo to show the value of checking is_cached(). The summary of this is that there is (in its current implementation anyway) real value in doing a check and returning the cached template before doing any logic or DB fetching if it is available. This could dramatically speed up your module if utilized properly. Check the demo module code for example. -
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1967
just implemented additional demo features to demonstrate the varying methods of clear_cache(). There is a lot of internal 'inline' documentation to help you understand how it works. Check the demo module code for more!
- Moderated by:
- Support
