vLIB
Welcome, Guest. Please login or register.
Did you miss your activation email?
Fri, 21. December 2007 - 08:59:35

Login with username, password and session length
Search:     Advanced search
Please register with your real name and do not post any SPAM! Violations: "Hk." and "Getagrip" => deleted
1.459 Posts in 346 Topics by 21 Members
Latest Member: Tim81
* Home Help Search Login Register
+  vLIB
|-+  English support
| |-+  vlibTemplate, vlibMimeMail, vlibDate
| | |-+  Cache / filemtime to recache
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Cache / filemtime to recache  (Read 586 times)
Andre
Guest
on: Sat, 10. May 2003 - 13:14:40

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
Guest
Reply #1 on: Mon, 12. May 2003 - 12:14:26

Oh yeah, I'll implement this in CVS.

Thanks for the fix.
Regards,

Kelvin
Logged
releasedj
Guest
Reply #2 on: Thu, 15. May 2003 - 16:43:02

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

Regards,

Kelvin
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!