Answer the question
In order to leave comments, you need to log in
Is it correct to cache the result from the database in a static property of the model class?
There is a Users model:
class Users extends CActiveRecord
{
public static $userInfo = null;
...
Answer the question
In order to leave comments, you need to log in
If your method that retrieves data from the cache completes earlier than the request from the database, then everything is fine.
But I would rather make a separate method that checks for the presence of data in the variable and, if there is none, then we make a request and enter the data into the variable and return it upon request in the same method. If there is data, then we get it from the cache and return it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question