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

From: Date: Sun, 14 Apr 2002 17:19:30 +0000
Subject: Re: [SMARTY-DEV] Changed cache_lifetime-handling and added expiration date
References: 1 2 3 4 5 6 7  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3704@lists.php.net to get a copy of this message
"Jason Sweat" <sweatjejm@mchsi.com> schrieb im Newsbeitrag news:012401c1e369$a68b41e0$bb0aa8c0@sweat.d2g.com... > 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"; > } This does not support real dynamic caching without access to the dynamic caching-times before "$t->is_cached". Norbert

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