Re: [SMARTY-DEV] Changed cache_lifetime-handling and added expiration date

From: Date: Sun, 14 Apr 2002 04:05:43 +0000
Subject: Re: [SMARTY-DEV] Changed cache_lifetime-handling and added expiration date
References: 1 2 3 4 5 6  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3692@lists.php.net to get a copy of this message
I handled a similar situation without modifying Smarty by creating a function: function cache_since($cache_time, $future_cache = 3600) { if ($cache_time > time()) { return $future_cache; } else { return (time() - $cache_time); } } and using like this (I wanted it to cache for 10 minutes during the business day, but the same content could be used all weekend ): $t->caching = true; if ('Sun'==strftime("%a")) { $t->cache_lifetime = cache_since(mktime(16,0,0,date('m'),date('d')-2,date('Y'))); $reason = 'Sunday'; } elseif ('Sat'==strftime("%a") || time() < mktime(8,40,0,date('m'),date('d'),date('Y')) ) { $t->cache_lifetime = cache_since(mktime(16,0,0,date('m'),date('d')-1,date('Y'))); $reason = ('Sat'==strftime("%a")) ? 'Saturday' : 'Before 8:40 AM on Weekday'; } else { $t->cache_lifetime = cache_since(mktime(16,0,0,date('m'),date('d'),date('Y')),600); $reason = "weekday"; } ----- Original Message ----- From: "Norbert Röcher" <norbert.roecher@t-online.de> To: <smarty-dev@lists.php.net> Sent: Saturday, April 13, 2002 12:45 AM Subject: Re: [SMARTY-DEV] Changed cache_lifetime-handling and added expiration date > "Norbert röcher" <norbert.roecher@t-online.de> schrieb im Newsbeitrag > news:20020412204526.47325.qmail@pb1.pair.com... > > > > "Monte Ohrt" <monte@ispi.net> schrieb im Newsbeitrag > > news:3CB73EBF.2050609@ispi.net... > > > At the same time, I want to try to avoid adding any more > > > user-configurable variables unless absolutely necessary. We > probably > > > just need to decide, for what reasons is each situation useful or > > makes > > > better sense? > 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. > > Regards, > Norbert > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.smarty.general (#3692) next »