2

I'm using cache in CActiveRecord as:

$myoboject = ListModel::model()->cache(60)->findAll();

According to documentation it caches the result set for 60 seconds.

I would like to ask, will it open a new DB connection if another request will come within 60 second ? What I think it should not do like this, instead it should fetch the cached data.

I'm having this problem because I wanted to avoid the multiple db connection being opened by a script and I want to cache the data for 60 seconds, and after that it can be invalidated.

Am I on the right track ? is this a normal behaviour ? will anybody please let me know if there is something wrong ?

I have used both Memcache and Sqlite.

1 Answer 1

1

According to some research, forum discussions and analyzing the CDConnection and CActiveRecord code, it is confirmed that it must open a new connection. So either we write our code to avoid this or wait for a feature. Till than we can use data caching by saving the data object into cache.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.