Home >Backend Development >PHP Tutorial >Example tutorial on docking memcache
Interface access log Data structure sharing
apiname Interface name
apiname[cnt]The number of interface accesses increases by one for each access. I have not solved the concurrency problem here;
apiname[cnt][n][spent_time] represents the number of visits and the time consumed
apinames This is an array recording all apinames. I use serialize to turn the array into a string
Next make a storage display
apinames = unserialize($apinames);
$arr = array();
# Foreach ($ Apinames as $ k = & gt; $ v) {
## $ key = $ v; $ [ $key]=$memcache->get($v.'[cnt]');
}
if($apiname){
$ CNT = $ Memcache- & GT; Get ($ Apiname. '[CNT]');
# $ r [$ i] ['ID'] = $ i;
# $ s s = $ apiname. '[CNT]'. "[". $ I. " ."[spent_time]";
$add_key = $apiname.'[cnt]'."[".$i."]"."[add_time]";
'Y-m-d H:i:s', $memcache->get($add_key));
}
For reference only
The next step is to store the session in memcache. We use Alibaba Cloud's memcache service PHP and the installed extension is memcached
We encountered some problems in this area. After two days of research, I finally figured it out. At first, I modified php.ini but it had no effect. Later I found that the configuration file has a priority php-fpm.d and there is another configuration file below it or php-fpm.conf. These two configuration files have the same priority. It is larger than php.ini, so you need to configure the latter first and then restart nginx and php-fpm
After solving this problem, I encountered another problem. It was memcache that could not be saved. Later I found out that it was the reason for memcached expansion. If The local installation is memcahched. When modifying the session storage path, you must write memcached in the handler. Remember not to write memcahe. It is the path. Do not add tcp to the path. Just write the service address and port number directly.
The above is the detailed content of Example tutorial on docking memcache. For more information, please follow other related articles on the PHP Chinese website!