dongxiongshi9952 2009-09-18 01:44
浏览 47

如何使用Memcache加速PHP?

I have enabled the memcache extension for my PHP Apache localserver server (XAMPP)

but I don't know how to use it to speed up my PHP scripts Is writing the following code in the top of every page I want to speed up is enough? or I should do something else?

       /* procedural API */
       $memcache_obj = memcache_connect('127.0.0.1', 11211);

       /* OO API */
       $memcache = new Memcache;
       $memcache->connect('127.0.0.1', 11211);

the phpinfo() shows the following details

        memcache support    enabled
        Active persistent connections   0
        Version 2.2.4-dev
        Revision    $Revision: 1.99 $

Thanks

  • 写回答

2条回答 默认 最新

  • doushi2902 2009-09-18 01:57
    关注

    You might want to consider using memcache_pconnect() instead but there are pros and cons to that.

    You've got memcache setup. It won't speed up anything unless you use it for something. There are four basic things you can cache:

    1. Loading stuff from a file;
    2. Loading stuff from a database;
    3. Loading stuff from a remote host; and
    4. Storing the result of something that takes significant time to calculate.

    Until you use it for something, it won't do anything.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP