PHP Memcache 扩展安装

环境

ubuntu 20.04

查看php 所有扩展

php --ini
php -m

apt-cache查看需要安装的memcached扩展

apt-cache search memcached php

安装memcached 扩展

sudo apt install php-memcache

检测memcache扩展是否已安装

php -m | grep memcache

PHP 连接 Memcached

test.php

<?php
$memcache = new Memcache;             //创建一个memcache对象
$memcache->connect('localhost', 11211) or die ("Could not connect"); //连接Memcached服务器
$memcache->set('key', 'huyongjian');        //设置一个变量到内存中,名称是key 值是test
$get_value = $memcache->get('key');   //从内存中取出key的值
echo $get_value;
echo PHP_EOL;

运行test.php

ubuntu@VM-0-14-ubuntu:~$ php test.php
huyongjian

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2021-10-02
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2021-11-03
  • 2021-05-21
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案