index : archweb32 | |
Archlinux32 website | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-07-27 10:08:00 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-07-27 10:08:00 +0200 |
commit | bc090c5b10cf05006644782a47ec94e62bd4661d (patch) | |
tree | 73d6511f30ee27dbf99c3a63dd4882001cdb2e2b /lib | |
parent | d448af861506c9b62a9185ff011e92d91688fc63 (diff) |
-rw-r--r-- | lib/helper.php | 18 |
diff --git a/lib/helper.php b/lib/helper.php index 5ec1f0f..ffa5943 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -87,13 +87,19 @@ function format_time_duration($val) { function git_url($repository,$type,$commit,$path,$line = null,$commit_is_hash = null) { global $git_available; - # TODO: we might want to cache this value (with memcached ?) if (!isset($git_available)) { - $git_available = - preg_match( - "/ 200 OK$/", - get_headers("https://git.archlinux32.org/archlinux32/packages")[0] - ) == 1; + $memcache = new Memcache; + $memcache->connect('localhost', 11211) or die ('Memcached Connection Error'); + $git_available = $memcache->get('git_available'); + if ($git_available === false) { + $git_available = + preg_match( + "/ 200 OK$/", + get_headers("https://git.archlinux32.org/archlinux32/packages")[0] + ); + $memcache->set('git_available',$git_available,0,120); + }; + $git_available = $git_available == 1; } if (!isset($commit_is_hash)) $commit_is_hash = preg_match("/^[0-9a-f]{40}$/",$commit)==1; |