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 
Problem with Cache_Lite_Function

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



Joined: 06 Nov 2006
Posts: 4

PostPosted: Mon Nov 06, 2006 5:04 pm    Post subject: Problem with Cache_Lite_Function Reply with quote

I am having an issue with Cache_Lite_Function where the second of two function cache calls is not hitting the cache, ever. Basically I have two functions I am calling using Cache_Lite_Function, let's call them foo and bar. No matter which one I call first, the second always fails to hit the cache.

For example, if my program calls foo first then bar and I run it multiple times I alway see this behavior(except the first time of course):
--------

Call foo -> cache hit
Call bar -> cache miss

--------

If I switch up the order of the calls then I get this:

Call bar ->cache hit
Call foo ->cache miss

-------------

I have tried all kinds of different options but my base options are these:
Code:
$options = array('lifeTime' => 86400,
                         'cacheDir' => SGPATH_BASE . 'tmp' . DS,
                         'automaticSerialization' => TRUE,
                         'automaticCleaningFactor' => 20,
                         'hashedDirectoryLevel' => 1,
                         'defaultGroup' => 'imagine',
                         'dontCacheWhenTheResultIsFalse' => TRUE,
                         'pearErrorMode' => CACHE_LITE_ERROR_RETURN);


My main code is as follows:
Code:
    if (!($out1 = $myClass->foo())) {
          return "ERROR";
    }

    if (!($out2 = $myClass->bar())) {
         return "ERROR"
    }


I cannot explain this behavior. I am seeing the cached files in the cacheDir and it can read one of the two caches every time so it can't be file read/write problems. The fact that one always reads/writes correctly but the other misses the cache baffles me. And the fact that switching the order causes the other to work correctly definitely adds to the confusion.

Please help! Confused
Back to top
View user's profile Send private message
Wolverine



Joined: 06 Nov 2006
Posts: 4

PostPosted: Mon Nov 06, 2006 5:54 pm    Post subject: Reply with quote

more info. After adding custom debugging to Lite.php it is reporting that the second cache does not exists. However, the file does exist and has the same permissions as all the other cache files.

So I started looking at the filename each run, and it appears that if you call a cached function inside a class using $this it generates a different filename each time for the second called function because $this has changed.

So my function calls inside my class are

return $this->_cache->call(array(&$this, 'foo'));
return $this->_cache->call(array(&$this, 'bar'));

because $this has changed by the time 'bar' is called it apparently changes the serialization name of the cache. This appears to be why it misses every time. So using cache_lite_function in this way will give strnge results.
Back to top
View user's profile Send private message
problems



Joined: 26 Feb 2010
Posts: 1

PostPosted: Fri Feb 26, 2010 11:38 am    Post subject: Reply with quote

I can't understand this concept.
_________________
auto insurance quotes online
auto insurance quotes online
Back to top
View user's profile Send private message
Kurosakiichigo



Joined: 02 Mar 2010
Posts: 1

PostPosted: Tue Mar 02, 2010 3:17 pm    Post subject: Reply with quote

Can anyone explain what is a cache_lite function???
_________________
free baby samples
free baby samples
Back to top
View user's profile Send private message
visited



Joined: 10 Mar 2010
Posts: 1

PostPosted: Wed Mar 10, 2010 8:31 am    Post subject: Reply with quote

This is indeed possible with Cache-Lite of the PEAR library from PHP .
_________________
school uniforms
school uniforms
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