We have an Android App with a large number of users (about 300k) that uses PHP Yii Framework as web-service and Xcache as our cache system.
In the Main page of the app we have some statistics about app and top 6 users to show.
Is this a good way too cache the json output that requested by android every time (for a few hours)?
What is the best way to do that?
My code:
public function actionGetMainStats()
{
$result = Yii::app()->cache->get('mainStats');
if($result == null){
// calculate the mainStats Array
$mainStat = User::model()->androidMainStats();
Yii::app()->cache->set('mainStats', $calculatedArray, 100000);
}
echo CJSON::encode($mainStats);
}