3

I would like to use a PHP opcode cache, like APC and XCache.

TO have benefit from this cachers, do I have to change something on my php code or just install one of them?

I have seen there are APIs, do I have to use them?

Thank you

Dail
  • 31
  • 2

3 Answers3

0

The APIs are to exert manual control over how the caches work, but if they are properly installed and configured, they will "just work".

David Fells
  • 6,678
  • 1
  • 22
  • 34
0

About APC: you can just install APC and it will work.
If you want, you can adjust size of memory, allowed for APC.
And I recommend to set this setting:

apc.slam_defense = Off
OZ_
  • 12,492
  • 7
  • 50
  • 68
  • 1
    Care to add some reasoning behind your recommendation? – Nev Stokes May 08 '11 at 09:07
  • as in the php documentation for apc mentioned this setting is deprecated and replaced by apc.write_lock [link](http://www.php.net/manual/de/apc.configuration.php#ini.apc.slam-defense) – peaceman May 08 '11 at 09:40
  • @Nev Stokes my experience. Without this setting PHP will generate warnings very often. On loaded site it will mean impossible to use APC to cache user's data. I use last stable version of APC and I know, what about I'm talking. – OZ_ May 08 '11 at 11:15
  • @peaceman write_lock affects only opcode cache, when I'm talking about users cache. – OZ_ May 08 '11 at 11:16
  • Chill OZ_ I wasn't trying to diss your knowledge or anything. People are more likely to follow suggestions if you explain them. FWIW, I too use APC and have no issues whatsoever. – Nev Stokes May 08 '11 at 14:11
0

As previous posters have mentioned, once properly installed, APC will "just work" by storing the compiled PHP code to save this having to be done each time. There is nothing else for you to do.

However, you can also leverage APC to store settings that you may have previously got from a database lookup for example. Take a look at apc_store and related functions.

Nev Stokes
  • 9,051
  • 5
  • 42
  • 44