vLIB
Tue, 02. January 2007 - 07:15:02 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Please register with your real name and do not post any SPAM!
 
   Home   Help Search Members Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Cache / filemtime to recache  (Read 268 times)
0 Members and 0 Guests are viewing this topic.
Andre
Newbie
*
Offline Offline

Posts: 6


View Profile
on: Sat, 10. May 2003 - 13:14:40
Reply with quoteQuote

I have finished two project with the vlibTemplateCache and I always have to explain the Designers what they have to to when they edit the Templates because of the Caching.
Yesterday when I cleaned my teath I've had an Idea: We can check if the Template was modified when we take a look at the modified filetime of the template (filemtime()) and compare it with the filetime of the cachefile. Today I started to make a closer look at the cache.php and i saw that you already was so clever to implement that. Then I started to make several Tests but it didn't work as I expected.

Now I want to explain the bug: (Sorry for my poor english i'm german)
cache.php:
Code:

...

_checkCache$tmplfile

...

 // if it's expired

if filemtime$this-_cachefile + $this-OPTIONS'CACHE_LIFETIME' date'U'



|| filectime$this-_cachefile filemtime$tmplfile

$this-_cacheexists = 0;

return false; // so that we know to recache



Well this would be ok but

...

function _createCache$data

    $f = fopen $cache_file, w;

// there you open the file and delete it.

...

touch $cache_file;

// now you change the 'last modified' time of the cachefile but the filectime of the cachfile is the same because the cachefile has already existed.

// But you check

filectime$this-_cachefile filemtime$tmplfile

and this is after the first modification of the template file always true and vlib never uses the cache. There's the problem. Either you delete the file bevor fopen or how i've solved the problem you check not the ctime, you check the mtime of the cachefile by

filemtime$this-_cachefile filemtime$tmplfile ... template file has modified so the cachefile is 'older' than the templatefile - recache. ...


With this codition in the if-clause it works great and i never need to recache() or clearCache().

I hope I've written all correctly and easy to understand.

mfg Andre
}
Logged
releasedj
Administrator
Hero Member
*****
Offline Offline

Posts: 260


View Profile
Reply #1 on: Mon, 12. May 2003 - 12:14:26
Reply with quoteQuote

Oh yeah, I'll implement this in CVS.

Thanks for the fix.
Regards,

Kelvin
Logged
releasedj
Administrator
Hero Member
*****
Offline Offline

Posts: 260


View Profile
Reply #2 on: Thu, 15. May 2003 - 16:43:02
Reply with quoteQuote

This has been updated and a new release is available for testing.

Regards,

Kelvin
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!