From 97ea828532c564563fcd7ac45551befb1fa4cd98 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Mon, 4 Oct 2010 15:42:21 +0000 Subject: [PATCH] Use a persistent cache through Pluf_Cache to speed up cert queries. --- src/IDF/Scm/Monotone.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/IDF/Scm/Monotone.php b/src/IDF/Scm/Monotone.php index f55d32f..13a33e1 100644 --- a/src/IDF/Scm/Monotone.php +++ b/src/IDF/Scm/Monotone.php @@ -157,9 +157,11 @@ class IDF_Scm_Monotone extends IDF_Scm */ private function _getCerts($rev) { - static $certCache = array(); - - if (!array_key_exists($rev, $certCache)) { + $cache = Pluf_Cache::factory(); + $cachekey = 'mtn-plugin-certs-for-rev-' . $rev; + $certs = $cache->get($cachekey); + + if ($certs === null) { $out = $this->stdio->exec(array('certs', $rev)); $stanzas = IDF_Scm_Monotone_BasicIO::parse($out); @@ -183,10 +185,10 @@ class IDF_Scm_Monotone extends IDF_Scm } } } - $certCache[$rev] = $certs; + $cache->set($cachekey, $certs); } - return $certCache[$rev]; + return $certs; } /**