I've action `show` that display article text with images from
database.
Every article at the bottom have `add comment` form with antispam
feature.
I would like to cache entire action to reduce page load time (many db
queries).
BUT I need to execute two lines of antispam code on each request:

    $antispam = new AntiSpam(); $antispam_string = $antispam->rand(5);
    $this->getUser()->setAttribute('antispam', $antispam_string);

I've tried to use several methods:
1) just cache action. code in template or partial
show:
  enabled:     on
_addcomment:
  enabled:     off

Action not executed. good. Template cached.
Antispam code inside cached partial/template NOT executed

2) cache only partials inside template, code in template/partial:
show:
  enabled:     off
_addcomment:
  enabled:     off
_rubrica:
  enabled:     on
_author:
  enabled:     on
_author:
  enabled:     on

Action executed. Many db queries.
Antispam code executed.

But it seems that second method has almost similar timings when the
cache is completly off.

SO, the question is :

      "Is there some other method to execute two lines of code in
cached action ?"

Any ideas? May be I'm reinventing the wheel ?

Thanks in advance.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to