Yii Framework Forum: Activerecord Table Schema Caching - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Activerecord Table Schema Caching Rate Topic: -----

#1 User is offline   Alegz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 23-July 12

Posted 10 November 2012 - 02:56 AM

Hi.

Recently I was using active record, and faced some problem.
I wanted to configure my db component to cache table schema.
I put in my main.php, in db component parameter
schemaCachingDuration = 86400

Manual: http://www.yiiframew...Duration-detail

According to the manual this option says to db to cache data about schema for 86400 seconds (one day), but when I switched on profiling I see this
system.db.CDbCommand.query(SHOW COLUMNS FROM `some_table`)

If I am not mistaking this request should be run once in a day, but Yii does it every controller load.

Maybe I missed something.
Have somebody faced this problem?
0

#2 User is offline   MehdiA 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 15-November 12

Posted 15 November 2012 - 07:24 PM

I had the same issue, did you find an answer Algez?
0

#3 User is offline   Bijay Rungta 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 27-August 10

Posted 17 November 2012 - 12:42 PM

I was also trying to figure this out and found the solution.

You must enable caching for it to be effective.

Notice this:
If greater than 0 and the primary cache is enabled, the table metadata will be cached.

To set Caching, see Caching Overview

You will have to add Caching setting in Configuration, For Memcache you can use this:

    'components'=>array(
        ......
        'cache'=>array(
            'class'=>'system.caching.CMemCache',
            'servers'=>array(
                array('host'=>'server1', 'port'=>11211, 'weight'=>60),
                array('host'=>'server2', 'port'=>11211, 'weight'=>40),
            ),
        ),
    ),

0

#4 User is offline   Alegz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 23-July 12

Posted 29 November 2012 - 12:32 PM

View PostBijay Rungta, on 17 November 2012 - 12:42 PM, said:

I was also trying to figure this out and found the solution.

You must enable caching for it to be effective.

Notice this:
If greater than 0 and the primary cache is enabled, the table metadata will be cached.

To set Caching, see Caching Overview

You will have to add Caching setting in Configuration, For Memcache you can use this:

    'components'=>array(
        ......
        'cache'=>array(
            'class'=>'system.caching.CMemCache',
            'servers'=>array(
                array('host'=>'server1', 'port'=>11211, 'weight'=>60),
                array('host'=>'server2', 'port'=>11211, 'weight'=>40),
            ),
        ),
    ),


Yep this is a solution, I found that out after 2-3 days.
I didn't mension that my cache class was CDummyCache, that was the reason.
Thank you for reply.

By the way, memcache is the best way of caching only if you don't run your project on Pentium 1. =)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users