RoboTamer
RoboTamer

Reputation: 3524

Clarification needed on Alternative PHP Cache

I am playing around with the Alternative PHP Cache APC, and I can't find answers to some of my questions.

  1. If a file has been loaded in to the bytecode cache, either by APC automaticlly or implicitly via apc_compile_file(), is the php function include aware of that? Does include use the cache, when it needs the file rather then accessing the file from disc?
  2. If so, how could I test that, to see if it works? Something that shows me that the file on disc wasn't accessed would be good enough.
  3. Some of the files automatically loaded in to the APC system cache are just pure html files, or 99% html, with a few php variables (Template files). They don't take much space in the APC cache but still, is there a way to exclude files, or whole folders? Tell APC not to even consider loading them?
  4. I been using SQLite or Redis database as session save handler backend, depending on the project. Often it will not make sense to use both APC and Redis on the same project. What do you think about keeping session data in APC?

Thank you,

Upvotes: 1

Views: 375

Answers (2)

Your Common Sense
Your Common Sense

Reputation: 157989

For the 1 and 2 I have no proof but I believe the caching is done for the included files as well. Otherwise it will just make no sense. There are huge applications with single entry point and other files included at various levels. Don't you think all these apps cannot utilize APC at all?

For the pure html files I'd suggest you to use readfile() instead of include() and thus involve no caching at all.

For the files with a few php variables (Template files) you HAVE to keep them in cache as the entire point of caching is skipping of parsing part. Otherwise you will make PHP parse these files all the time, which is not your desire, I believe.

You can use APC for storing sessions. I dunno ifit's better or not. Just try and see which better suits you. There are no strict standards, I believe.

Upvotes: 2

zerkms
zerkms

Reputation: 255115

  1. Depending on apc.stat directive before retrieving file's opcode from the memory php will check if file has been modified (only stat is requested, no content reading)
  2. You can set apc.stat as 0. Include some file, delete it and nothing should happen. The script should work as the file hasn't been deleted
  3. Yes, use apc.filters
  4. Probably it will be a little faster, but APC is just a cache, so it doesn't guarantee the data will exist in any particular moment it should

Upvotes: 1

Related Questions