Hello all,

I've been looking for a way to speed up requestAction and wanted to
share a hack I came up with.  It seems that the main problem is that
the SessionComponent is re-instantiated and a new session is started
each time.

First i modified SessionComponent and added the following function:

        function &getInstance() {
                static $instance = array();
                if (!$instance) {
                        $instance[0] =& new SessionComponent;
                }
                return $instance[0];
        }

(Yes, it's very similar to the Configure::getInstance() ;-)

Then in cake/libs/controller/component.php I removed lines 120-126 and
inserted this:

        if ($componentCn == 'SessionComponent') {
                $param = strip_plugin($this->__controller->base, 
$this->__controller-
>plugin) . '/';
                $this->__controller->{$component} =&
SessionComponent::getInstance();
        } else {
                $param = null;
                $this->__controller->{$component} =& new $componentCn($param);
        }
        $loaded[$component] =& $this->__controller->{$component};

Using this singleton pattern for SessionComponent I noticed a x2
performance improvement for requestAction() (ymmv).  I am using cake
version 1.1.16.5421, but I imagine the same can be done with other
cake versions.

Regards,

Adam

P.S. have been a big fan of cake since v0.2.6 - keep up the good work
guys!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to