Yiimemcache is an example of memcache usage in the Yii Framework. An example of memcache usage in the Yii Framework. yiimemcache this article describes the usage of memcache in the Yii Framework. Share it with you for your reference. The specific analysis is as follows: the current company uses the memcache usage instance in the Y Yii Framework, yiimemcache
This article describes the usage of memcache in the Yii Framework. Share it with you for your reference. The specific analysis is as follows:
Currently, the company uses the YII Framework, which involves many things and many things that can be learned. in the past, the company has never been familiar with memcache, but I have heard of it, but it has never been used. Now I have a chance to use it. let's take my project as an example!
My project is a mobile phone ranking list, but the ranking list is refreshed every 15 minutes. The ranking list has one of the top three, which may be the top three in the first 15 minutes, maybe the next 15 minutes will be the top three of others, and the product requirements, as long as the top three of them are to be awarded, I think for a long time, finally, we decided to use memcache to save the top three pieces of information on the list every 15 minutes. The code is as follows:
The code is as follows:
Public function getChargeRank3 ()
{
$ Startime = '2017-04-10 00:00:00 ';
$ Endtime = '2017-04-30 23:59:59 ';
$ SQL = "select top 3 user_id, sum (point) as total from table where state = 5 and cp_id> = 11 and cp_id <= 19 and pay_time> = '$ startime' and pay_time <=' $ endtime'
Group by user_id order by total desc ";
$ Result = Yii: app ()-> controller> createCommand ($ SQL)-> queryAll ();
$ Cache = yii: app ()-> cache-> get ($ key );
If ($ cache! = False)
{
Foreach ($ result as $ key => $ val)
{
// Here is the internal gift code, which is inconvenient to reveal
}
}
YII: app ()-> cache-> set ($ key, $ result, strtotime ($ endtime); // write the top three to the cache
}
I hope this article will help you design PHP programs based on the Yii Framework.
The following example describes the usage of memcache in the Yii Framework. Share it with you for your reference. The specific analysis is as follows: the current company uses Y...