Home > Backend Development > PHP Tutorial > Example tutorial on docking memcache

Example tutorial on docking memcache

零下一度
Release: 2023-03-10 17:00:01
Original
1229 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template