SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    APC doesn't seem to be retaining values

    I've installed APC, it's enabled and is showing up in phpinfo(), calling extension_loaded('apc') returns true, and calls to apc_fetch() and apc_store() aren't giving errors.

    I have code that looks like:
    PHP Code:
    function getValue($key) {
      if(
    false===($val apc_fetch($key)) {
        
    $val function_that_computes_val($key);
        
    apc_store($key,$val)
      }
      return 
    $val;

    but some checking shows that the call to apc_fetch() is never succeeding.
    Debugging has shown:
    - the call to apc_store() returns TRUE
    - putting another apc_fetch() just after the apc_store() returns the expected value

    When I put a call to apc_cache_info() at the bottom of my code, only the files from the current request are listed as being cached, even after browsing multiple pages (that include/require different files).

    phpinfo() shows that all the apc directives are using the default values, nothing I've come across seems to suggest that this would cause problems.

    This is with PHP 5.2.0-8etch7 (on a Debian server), running as FastCGI.

    Any suggestions as to what might be happening would be great, I'm happy to provide more info if you think it would help.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    They distributed a file in the pecl package (I think) called apc.php which lets you look at what is cached, for how long, ttl (time to live) etc etc.

    Maybe that doesn't answer your Q, but does at least let you peer inside at what is happening ...
    HTH

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just found that and had a look, and the only thing it's listing as being cached is the apc.php file itself, which seems consistent with the memory being 'lost' on each page load.

    I've been doing some more experimenting, and something I've noticed while comparing the apc. directives, is that the value for "apc.mmap_file_mask" changes each time I reload a phpinfo() page... and (it just occured to me while writing this) checking the apc.php always shows an uptime of '0 minutes', which doesn't seem to be a good sign.

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems PHP running as CGI can't make use of APC as the shared memory goes at the end of each request, which makes sense I guess. Oh well.

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Sad. Its a boon.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •