tags:

views:

33

answers:

1

We use the APC user cache in our application, but I've started noticing various problems in our unit tests specifically related to the APC tests.

It seems that eventually APC starts failing to store and retrieve results; while most of the tests continue to run correctly (as they just rebuild data if it's not recovered from the cache) the tests that specifically test that caches are emptied or repopulated when they should be fail, which is somewhat annoying. The same tests run fine if they are ran in isolation, rather than as part of the whole test suite).

Questions

  • Has anyone else had similar problems? I can't seem to find much on this through google, aside from problems with the slam_defence setting breaking unit tests (which doesn't seem to be my problem, as it doesn't display any error messages for me).
  • Does anyone know how to get more debugging info out of APC? I detect failure by checking the return code of apc_store() and passing the extra success parameter to apc_fetch(), but all I get from that is a boolean success/failure status; no details on which I can follow up on.
+1  A: 

My guess would be that perhaps the cache is full. In your application this is something you should be able to handle (never assume the items exist in cache). I'm not aware of how APC caches or expires stuff, so it is weird that 'later stuff' isn't retained.

In the case of your unittests, would calling apc_clear_cache('user') for every test work?

Evert
It's a good thought, but in order to ensure that the state is the same for each test we are already calling apc_clear_cache('user') in the setUp call for each test.
El Yobo
If that's true, then I would see if I can get a short script that consistently triggers the problem and report a bug.
Evert
Actually, it turns out you were more or less correct. The problem is occurring because the cache is full, despite our attempts to empty it. Calling apc_clear_cache fails to free the memory; even calling apc_delete on each and every item fails to free the memory. Any ideas about this?
El Yobo
No idea really, sorry.. create a reproducable script and write a bug report.
Evert