memcached缓存服务器

1、安装
安装
sudo apt install memcached

查看服务状态
sudo systemctl status memcached

查看文件位置
sudo whereis memcached

查看版本号
sudo memcached --version

日志
/var/log/memcached.log

2、配置

配置文件位置
/etc/memcached.conf


3、telnet连接测试
https://www.runoob.com/Memcached/Memcached-tutorial.html
连接
telnet 127.0.0.1 11211

查看服务状态信息
stats

退出
quit

4、thinkphp连接
安装php memcached扩展
sudo apt install zlib1g-dev
sudo apt install libmemcached-dev

https://pecl.php.net/package/memcached/
https://github.com/php-memcached-dev/php-memcached
wget https://pecl.php.net/get/memcached/memcached-3.1.3.tgz

$ phpize
$ ./configure
$ make
$ make test
$ sudo make install (memcached.so自动安装到 /usr/lib/php/20170718 )

编辑/etc/php/7.2/fpm/php.ini
extension=memcached

重启php-fpm服务
sudo systemctl restart php7.2-fpm

phpinfo中查找 memcached

E:svn esttpapiappsconfig.php 配置
    'cache'                  => [
        // 驱动方式
        'type'   => 'Memcached',
        // 缓存保存目录
        'path'   => CACHE_PATH,
        // 缓存前缀
        'prefix' => '',
        // 缓存有效期 0表示永久缓存
        'expire' => 0,
        'host'=>'192.168.1.251',
        'port'=>11211,
    ],
    
读取、写入、删除、清空参考:
https://www.kancloud.cn/manual/thinkphp5/118131

原文地址:https://www.cnblogs.com/xiaomacs/p/11697167.html