Update of /cvsroot/fink/web/pdb In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv10596/web/pdb
Modified Files: browse.php functions.inc index.php package.php Log Message: set cache headers to allow squid to keep things around Index: functions.inc =================================================================== RCS file: /cvsroot/fink/web/pdb/functions.inc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- functions.inc 5 Dec 2007 19:04:34 -0000 1.2 +++ functions.inc 5 Dec 2007 21:18:31 -0000 1.3 @@ -28,6 +28,27 @@ ); } +function handle_last_modified($key, $query) { + $last_modified = memcache_get_key($key); + if (!$last_modified) { + $q = clone($query); + $q->setFields(array("infofilechanged")); + $q->setSort(array("infofilechanged desc", "rel_id desc", "pkg_id desc")); + $q->setRows(1); + $q->setRaw(true); + $r = $q->fetch(); + if ($r != null && $r->response->numFound >0) { + $date = $r->response->docs[0]->infofilechanged; + $last_modified = date_create($date)->format('D, d M Y H:i:s') . ' GMT'; + memcache_set_key($key, $last_modified); + } else { + $last_modified = gmtime('D, d M Y H:i:s') . ' GMT'; + } + } + header("Last-Modified: $last_modified"); + return $last_modified; +} + function format_solr_date($date) { $returnval = date_create($date)->format("r"); $returnval = preg_replace('/ \+\d+$/', ' (UTC)', $returnval); @@ -152,11 +173,11 @@ } public function getSort() { return $this->sort; } - public function setSort($sort) { $this->sort = $sort; } - public function addSort($sort) { array_push($this->sort, $sort); } + public function setSort($sort) { $this->sort = $sort; return $this; } + public function addSort($sort) { array_push($this->sort, $sort); return $this; } public function getQuery() { return $this->query; } - public function setQuery($query) { $this->query = $query; } + public function setQuery($query) { $this->query = $query; return $this; } public function addQuery($query, $required = false, $exclude = false) { if ($required) { @@ -166,6 +187,7 @@ } else { array_push($this->query, $query); } + return $this; } public function fetch() { Index: package.php =================================================================== RCS file: /cvsroot/fink/web/pdb/package.php,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- package.php 5 Dec 2007 20:49:12 -0000 1.55 +++ package.php 5 Dec 2007 21:18:31 -0000 1.56 @@ -9,27 +9,9 @@ include_once "releases.inc"; $package = basename($HTTP_SERVER_VARS["PATH_INFO"]); - -$last_modified = memcache_get_key('pdb-last-modified-' . $package); -if (!$last_modified) { - $q = new SolrQuery(); - $q->addField("infofilechanged"); - $q->addSort("infofilechanged desc"); - $q->addSort("rel_id desc"); - $q->addSort("pkg_id desc"); - $q->addQuery("name_e:\"$package\"", true); - $q->setRows(1); - $q->setRaw(true); - $r = $q->fetch(); - if ($r != null && $r->response->numFound >0) { - $date = $r->response->docs[0]->infofilechanged; - $last_modified = date_create($date)->format('D, d M Y H:i:s') . ' GMT'; - memcache_set_key('pdb-last-modified-' . $package, $last_modified); - } else { - $last_modified = gmtime(', d M Y H:i:s') . ' GMT'; - } -} -header("Last-Modified: $last_modified"); +$q = new SolrQuery(); +$q->addQuery("name_e:\"$package\"", true); +handle_last_modified('pdb-last-modified-' . $package, $q); include_once "header.inc"; Index: browse.php =================================================================== RCS file: /cvsroot/fink/web/pdb/browse.php,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- browse.php 5 Dec 2007 19:04:34 -0000 1.13 +++ browse.php 5 Dec 2007 21:18:31 -0000 1.14 @@ -9,12 +9,15 @@ $pdb_scripts = true; include_once "handle_options.inc"; -include_once "header.inc"; include_once "memcache.inc"; include_once "functions.inc"; include_once "releases.inc"; include_once "sections.inc"; +handle_last_modified('pdb-browse-last-modified', $query); + +include_once "header.inc"; + ?> <h1>Browse packages</h1> Index: index.php =================================================================== RCS file: /cvsroot/fink/web/pdb/index.php,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- index.php 5 Dec 2007 19:04:34 -0000 1.28 +++ index.php 5 Dec 2007 21:18:31 -0000 1.29 @@ -6,13 +6,17 @@ // 2 hours, this page does not change much $cache_timeout = 7200; -include_once "header.inc"; include_once "memcache.inc"; include_once "functions.inc"; include_once "releases.inc"; include_once "sections.inc"; ini_set("memory_limit", "24M"); +$q = new SolrQuery(); +$q->addQuery("dist_visible:true", true); +$update_date = handle_last_modified('pdb-last-modified', $q); + +include_once "header.inc"; ?> @@ -44,7 +48,6 @@ <? $pkgcount = memcache_get_key('pdb-package-count'); -#$update_date = memcache_get_key('pdb-last-updated'); if (!$pkgcount) { $names = array(); @@ -61,22 +64,6 @@ } } -if (!$update_date) { - $q = new SolrQuery(); - $q->addQuery("dist_visible:true", true); - $q->addField("infofilechanged"); - $q->addSort("infofilechanged desc"); - $q->setRows(1); - $q->setRaw(true); - $r = $q->fetch(); - if ($r != null) { - $update_date = $r->response->docs[0]->infofilechanged; - if ($update_date) { - memcache_set_key('pdb-last-updated', $update_date); - } - } -} - $dyndate = date_create($update_date)->format('U'); $seccount = count($sections); ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Fink-commits mailing list Fink-commits@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.cvs