PEAR Cache_Lite and Php Errors

Discussion in 'PHP' started by jack, Jul 26, 2009.

  1. #1
    I've started using PEAR Cache_Lite on some of the sites I'm working on a couple of months ago and it's great...but I ran into a bit of a problem :

    My site code is something like this :

    <?php 
    
    require ("cache path....."); 
    $options = array(
     'cacheDir'        =>'cache/',
     'writeControl'    => 'true',
     'readControl'     => 'true',
     'fileNameProtection' => false,  
     'readControlType' => 'md5'
    );
    $cache = new Cache_Lite_Output($options);
    $cache->setLifeTime(36000);
    $name="some name here";
    if (!($cache->start($name,"cache")) ) { 
    
    [B]error_reporting(0); [/B]
    
    //my main site code here
    .............
    
    $cache->end();
    }
    
    ?>
    Code (markup):
    My problem is that Cache_Lite saves a empty cache file when MySql/PHP fails and the script "dies" (and the output buffer is empty).

    How can I prevent this from happening ?
    Thanks .
     
    jack, Jul 26, 2009 IP
  2. hydn

    hydn Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Any reason why you opted for PEAR Cache_lite over opcode caches like eA, APC and xcache?

    PS. I also tried it once but it was too much manual work to setup files (maybe there's an easier way)
     
    hydn, Jul 26, 2009 IP
  3. jack

    jack Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm also using eAccelerator which helps a lot too ...but output caching(PEAR Cache_lite) really makes a big difference for my sites - no PHP(except the PEAR files that manage the cache) and no MySQL queries are executed for days on my server. Settings up Cache_Lite takes some time but if you get it working and auto refreshing parts of the cache on events like new posts, new comments , etc it really speeds up any site and the server load goes down which means lower hardware/hosting costs.
     
    jack, Jul 28, 2009 IP
  4. jack

    jack Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    any ideas ?
     
    jack, Aug 1, 2009 IP