PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Cache_Lite troubles

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Caching
View previous topic :: View next topic  
Author Message
yonta



Joined: 28 Sep 2006
Posts: 2

PostPosted: Thu Sep 28, 2006 5:52 pm    Post subject: Cache_Lite troubles Reply with quote

Hi Smile

I simply can't solve this. i'm trying to use pear's Cache_lite for the first time but it is unable to correctly remove cache files and detect if the cache file is good. I mean 'correctly' remove because it does empty the file but doesn't remove it and when a new call to cache->get is made, it just shows an empty page.

When a call to remove or clean is made, it echos 'unable to remove cache file'. I've even tried setting the permission to 777 on the cache directory but to no avail.

Of course, if i turn off caching everything works.

My php version is 4. Please please help

Here's my script (part of the whole controller script):

Code:

function banners_Controller()//contructor
   {
      $this->objCache = new Cache_Lite(array('cacheDir' => 'cache/',
                           'lifeTime' => 3600,
                           'automaticCleaningFactor '=>100,
                           'pearErrorMode' => CACHE_LITE_ERROR_DIE));
   }
function banners_List()
   {
      if (CACHING === true && $data = $this->objCache->get('ban_list','banners', false))
      {
         echo($data);
      } else {

         $this->_start();//include some scripts & set some variables
         require 'Savant2.php';
         $this->tpl = new Savant2(array('template_path' => 'templates'));


         $list = $this->banners->banners_GetAll();
         $list === false ? trigger_error("Erro ao aceder à lista de banners.", E_USER_ERROR): '' ;

         $this->tpl->assign('banners', $list);
         $this->tpl->assign('path', LPATH_TO_BANNERS_IMAGES);
         CACHING == true? $data = $this->tpl->fetch('banners_list.tpl.php'): $data =$this->tpl->display('banners_list.tpl.php');
         CACHING == true? $this->objCache->save($data, 'ban_list'):'';
         return true;
         exit();
      }
   function banners_Insert($ban_photo, $ban_ispub)
   {
      if(empty($ban_photo) || $ban_ispub=='')
      {
         $_SESSION['feedback'] = 'Não se esqueça de seleccionar a imagem.';
         $this->banners_List();
         return false;
      }
      $this->_start();
      require 'fileupload.class.php';

      //clear cache
      CACHING == true? $this->objCache->remove('ban_list','banners'):'';
      CACHING == true? $this->objCache->clean():'';


      //upload
      $upload = new FileUpload($ban_photo, SPATH_TO_BANNERS_IMAGES, 'jpg');
      $new_name = $upload->rename_filename();
      $result = $upload->upload($new_name);
      if($result[0]=== false)
      {
         $_SESSION['feedback'] = $result[1];
         $this->banners_List();
         return false;
      }
      

      //insert into db
      $db_insert = $this->banners->banners_Insert('ban_'.$new_name, $ban_ispub);
      if($db_insert === false)
      {
         $_SESSION['feedback'] = 'Erro ao guardar novo banner.';
         $this->banners_List();
         return false;
      }
      $_SESSION['feedback'] = 'Banner inserido com sucesso!';
      $this->banners_List();
   }

Thanks for any help
_________________
do it, do it right, do it right now
Back to top
View user's profile Send private message
yonta



Joined: 28 Sep 2006
Posts: 2

PostPosted: Thu Sep 28, 2006 7:50 pm    Post subject: Update Reply with quote

I re-worked the directories and it no longer gives me that error.
I had
Classes ->
Lite.php
Cache ->
File.php
And i now have
Classes ->
Cache ->
Lite.php
Lite ->
File.php

But my script is still weird.
After a remove of the cache, the next time it calls get, it will simply output a blank page instead of regenerating the cache. I have to hit Refresh to view the built page.

Why?

update - here's the delete function

Code:

function banners_Delete($ban_id)
   {
      $this->_start();
      CACHING == true? $this->objCache->remove('ban_list','banners'):'';
      $result = $this->banners->banners_GetOne($ban_id);
      $image_name = $result['ban_photo'];
      if(!$result || $image_name=='')
      {
         $_SESSION['feedback'] = 'Banner escolhido não existe.';
         $this->banners_List();
         return false;
         exit();
      }
      @unlink(SPATH_TO_BANNERS_IMAGES.$image_name);
      unset($result);
      $result = $this->banners->banners_Delete($ban_id);
      if($result === false)
      {
         $_SESSION['feedback'] = 'Erro ao eliminar banner escolhido.';
         $this->banners_List();
         return false;
         exit();
      }
      $_SESSION['feedback'] = 'Banner eliminado com sucesso!';
      $this->banners_List();

   }

_________________
do it, do it right, do it right now
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Caching All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software