My company uses CakePHP as our application framework, and recently
upgraded to the 1.2 release.  Recently while doing performance testing
we noticed that the localization functions are eating up a lot more
time than they did with our old Cake version, and traced it to the new
caching scheme found in i18n.php.  (Previously, we had been using a
'homegrown' caching addition to this file.)

I believe I've pinned down the problem as follows.  Consider a page
which displays two strings:

md('seo', 'homepage.header');
md('default', 'Welcome to our site!');

Suppose the cache is already populated - with the seo domain only.
Then, on the 'seo' call:

$_this->domain is set to {$domain}_{$lang_code} - let's say you're
browsing in en-us, so this is seo_en_us.
$_this->__domains is empty, so it loads the cached domains from
seo_en_us.
The SEO domain is in the cache, so the function simply performs the
translation.

On the 'default' call:

$_this->domain is set to {$domain}_{$lang_code} - default_en_us.
$_this->__domains has been previously set by the 'seo' call, so no
cache is loaded.
The default domain is NOT in the cache, so the function loads it from
PO and sets $_this->__cache.

On the destruct afterwards:

$_this->domain is still whatever it was set to by the last call
(default_en_us).
$_this->domains is written out into the '_cake_core_' cache under the
key 'default_en_us'.

The next time we load the page, seo_en_us is again the first $_this-
>domain value, so we load the cached value from 'seo_en_us' - only
this value hasn't been updated, so we *again* read in the entire
default.po on the second call.  And so on, and so on ad infinitem.
This means that the localization cache is often underutilized in
localization schemes with multiple domains because we're reading from
one cache key and writing to another.

This was quite problematic for us because it increased the duration of
the afflicted localization calls by about 7.5x.  Once we removed the
domain dependence from the cache key, it worked fine.  Is this a
potential bug in Cake?

--Smiley

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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