]> source.dussan.org Git - nextcloud-server.git/commitdiff
Memcache binary executable searching
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Fri, 9 Jan 2015 13:13:02 +0000 (13:13 +0000)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Fri, 9 Jan 2015 13:18:00 +0000 (13:18 +0000)
It's slow, this makes it fast!

lib/private/helper.php

index 8e9b7d3b6f32d7ade2d286593f38c846d3b2d456..86cc0850bc31fb72b8d0fc7b5d6bb95e4a54d921 100644 (file)
@@ -882,13 +882,19 @@ class OC_Helper {
         * @return null|string
         */
        public static function findBinaryPath($program) {
+               $memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
+               if ($memcache->hasKey($program)) {
+                       return $memcache->get($program);
+               }
+               $result = null;
                if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) {
                        exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
                        if ($returnCode === 0 && count($output) > 0) {
-                               return escapeshellcmd($output[0]);
+                               $result = escapeshellcmd($output[0]);
                        }
                }
-               return null;
+               $memcache->set($program, $result, 3600);
+               return $result;
        }
 
        /**