We have an Android App with large number of users (about 300K) with lot of requests and calculations using Yii Framework as web-service.
we have a function named getUserRank that takes user_id & timePeriod to calculate the user rank according to 3 tables (using huge joins) and we use it in our app a lot for every single user.
/*
* get user rank of the user according to the specified period
* periods: 0-> all 1-> daily 2-> weekly 3-> monthly
*/
public function getUserRank($user_id, $timePeriod){
// piece of code
}
I use Xcache and mod_php on my server. Is this a good job to store all of the user ranks for few hours before requesting from database in such a way (to send them by json to the App)?
$rank = Yii::app()->cache->get($user_id.$timePeriod); // generate cache id using $user_id.$timePeriod
if($rank == null){
// calculate and populate the cache variable
}