 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Wolverine
Joined: 06 Nov 2006 Posts: 4
|
Posted: Mon Nov 06, 2006 5:04 pm Post subject: Problem with Cache_Lite_Function |
|
|
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!  |
|
| Back to top |
|
 |
Wolverine
Joined: 06 Nov 2006 Posts: 4
|
Posted: Mon Nov 06, 2006 5:54 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|
|