How to use memcache to speed up PHP?

I have included the memcache extension for my local Apache PHP server server (XAMPP)

but I don’t know how to use it to speed up my PHP scripts. Is writing the following code at the top of every page that I want to speed up enough? or should i 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);

phpinfo () shows the following data

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

thanks

+3
source share
2 answers

You may want to use it memcache_pconnect(), but there are pros and cons to this.

You have a memcache setup. It will not accelerate anything if you do not use it for something. There are four main elements that you can cache:

  • Downloading files from a file;
  • ;
  • ;
  • -, .

-, .

+6

, . Memcache : .

PHP , -, memcache - . , . , , ( TCP-) ( ).

, , , (, - ). .

, , . , , , . (, , hotch-potch SQL .) , . - , , . memcache, . .

, ( - ), . memcache, .

, , , , . , , . -.

IMO, , .

+2

Source: https://habr.com/ru/post/1717990/


All Articles