Suggested (downcompatible) Solution

From: Date: Sat, 13 Apr 2002 06:56:30 +0000
Subject: Suggested (downcompatible) Solution
References: 1 2 3 4 5 6  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-62@lists.php.net to get a copy of this message
"Norbert röcher" <norbert.roecher@t-online.de> schrieb: > Well, after a bag of sleep: what about just another status for > "caching"? > > caching = 0; -> no caching > caching = 1; -> expire by lifetime > caching = 2; -> expire by expiration > > This enables the user to choose without any "bad" consequences after an > update or a change. No need for "clear_cache" or anything like that. An > expire by lifetime would work, even after month of using "expiration" > and same in reverse. It could be made fully downcompatible to running > systems. I've done a little hack for this: change 1 (insert on line 1417): if ($this->cache_lifetime >= 0){ // expiration set $this->_cache_info['expires'] = $this->_cache_info['timestamp'] + $this->cache_lifetime; } else { // cache will never expire $this->_cache_info['expires'] = -1; } change 2 (replace [new] lines 1489-1492 with this): if ($this->caching == 2 && isset ($this->_cache_info['expires'])){ // caching by expiration time if ($this->_cache_info['expires'] >= 0 && (time() > $this->_cache_info['expires'])) { // cache expired, regenerate return false; } } else { // caching by lifetime if ($this->cache_lifetime > 0 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) { // cache expired, regenerate return false; } } This is fully downcompatible, tested and works just fine. No new params, just a new status ($caching = 2 -> 'cache by expiration'). Switching between $caching=1 and $caching=2 works also and has the expected effect. Regards, Norbert

« previous php.smarty.dev (#62) next »