Re: Changed cache_lifetime-handling and added expiration date

From: Date: Fri, 12 Apr 2002 18:07:22 +0000
Subject: Re: Changed cache_lifetime-handling and added expiration date
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-56@lists.php.net to get a copy of this message
"Norbert röcher" <norbert.roecher@t-online.de> schrieb im Newsbeitrag news:20020412185106.70662.qmail@pb1.pair.com... > Hi, > > i've done a little change to the current cvs-version of > smarty.class.php > > For each cached file now the expirationdate is written to the > cache_info and is used as indicator for "is_cached". Benefit is to > check if a cached file expired, independent from the current > lifetime-setting in smarty. The lifetime-setting is now only used to > set expiration-time. I think is is VERY usefull. > > change 1 (new line at 1417): > function _write_cache_file($tpl_file, $cache_id, $compile_id, > $results) > { > // put timestamp in cache header > $this->_cache_info['timestamp'] = time(); > $this->_cache_info['expires'] = time() + $this->cache_lifetime; > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > change 2 (line 1483 after upper change): > if ($this->cache_lifetime > -1 && (time() > > $this->_cache_info['expires'])) { > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Correction (fixes "never expire"-Problem): Change 1 should be extended to: if ($this->cache_lifetime >= 0){ // expiration set $this->_cache_info['expires'] = time() + $this->cache_lifetime; } else { // cache will never expire $this->_cache_info['expires'] = -1; } Change 2 should be: if (($this->_cache_info['expires'] >= 0 && (time() > $this->_cache_info['expires'])) { Sorry... Regards, Norbert

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