Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yum::t cache performance #195

Open
abos5 opened this issue Oct 8, 2014 · 0 comments
Open

Yum::t cache performance #195

abos5 opened this issue Oct 8, 2014 · 0 comments

Comments

@abos5
Copy link

abos5 commented Oct 8, 2014

In a simple page, there are more than 67 invocation like below

Serving "yum_translations_en_us_yum" from cache trace cache 10:34:22.391621
Serving "yum_translations_en_us_yum" from cache trace cache 10:34:22.392180
Serving "yum_translations_en_us_yum" from cache trace cache 10:34:22.392729
...

Obviously, it is expensive.

So, maybe there could be some other strategy like what I have done in my project.(But I have to add namespace and etc. into the source code in Yum.php . Expecting better ideas)

...
class Yum extends yum\user\models\Yum
...
public static $messages;//new 
...
public static function t
...
if(isset(self::$messages[$language]) and isset(self::$messages[$language][$category]) ) {
    $messages = self::$messages[$language][$category];//new 
} else if(Yii::app()->cache) {
    $messages = Yii::app()->cache->get($cache_id);
    self::$messages[$language][$category] = $messages;//new 
}
...

    if(Yii::app()->cache)
        Yii::app()->cache->set($cache_id, $messages);
    self::$messages[$language][$category] = $messages; //new 
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant