一,关于yac项目:
1,代码地址https://github.com/laruence/yac2,鸟哥博客上的介绍:
https://www.laruence.com/tag/yac
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,下载yac源码:
root@lhdpc:/usr/local/source# git clone https://github.com/laruence/yac 正克隆到 'yac'... remote: Enumerating objects: 1339, done. remote: Counting objects: 100% (296/296), done. remote: Compressing objects: 100% (192/192), done. remote: Total 1339 (delta 185), reused 186 (delta 96), pack-reused 1043 接收对象中: 100% (1339/1339), 274.73 KiB | 910.00 KiB/s, 完成. 处理 delta 中: 100% (792/792), 完成.
说明:如果没安装git可以用 apt-get install git 安装git命令
三,安装yac
1,生成configureroot@lhdpc:/usr/local/source# cd yac/ root@lhdpc:/usr/local/source/yac# /usr/local/soft/php8/bin/phpize Configuring for: PHP Api Version: 20210902 Zend Module Api No: 20210902 Zend Extension Api No: 4202109022,配置
root@lhdpc:/usr/local/source/yac# ./configure --with-php-config=/usr/local/soft/php8/bin/php-config3,安装:
root@lhdpc:/usr/local/source/yac# make && make install … Installing shared extensions: /usr/local/soft/php8/lib/php/extensions/no-debug-non-zts-20210902/4,修改php配置使生效:
root@lhdpc:/usr/local/source/yac# cd /usr/local/soft/php8/etc/ root@lhdpc:/usr/local/soft/php8/etc# vi php.ini添加以下两行
extension_dir = /usr/local/soft/php8/lib/php/extensions/no-debug-non-zts-20210902/ extension = yac.so
四,查看效果
1,重启php-fpm服务root@lhdpc:/usr/local/soft/php8/etc# systemctl restart php-fpm.service2,查看phpinfo:
五,测试yac的应用
1,编写代码: setcache.php<?php $yac = new Yac("goods"); $yac->add('a', 'value a'); $yac->add('b', [1,2,3,4]); echo "set end<br/>";getcache.php
<?php $yac = new Yac("goods"); echo $yac->get('a')."<br/>"; // value a echo $yac->a."<br/>"; // value a print_r($yac->get('b'));2,测试: 写入: 读取
六,查看php的版本:
root@lhdpc:~# php --version PHP 8.1.1 (cli) (built: Dec 20 2021 16:12:16) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.1, Copyright (c) Zend Technologies with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies