diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-09 17:46:36 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-09 17:46:36 +0100 |
commit | d4355cafc6b9bfaa35658a6bb773df79be7463ce (patch) | |
tree | 68ed5f8be5526de3a5aa2c64c913b679d823ea0f /lib | |
parent | b1031c63557cdf93601b2749611e14ab3c77c28e (diff) | |
parent | c29138311614cba8bc4699a0afa485aefe621b6b (diff) | |
download | nextcloud-server-d4355cafc6b9bfaa35658a6bb773df79be7463ce.tar.gz nextcloud-server-d4355cafc6b9bfaa35658a6bb773df79be7463ce.zip |
Merge pull request #13192 from owncloud/cache_binary_path
Use memcache for findBinaryPath
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/helper.php | 10 | ||||
-rw-r--r-- | lib/private/memcache/factory.php | 4 | ||||
-rw-r--r-- | lib/private/memcache/null.php | 35 |
3 files changed, 45 insertions, 4 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index 8e9b7d3b6f3..86cc0850bc3 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -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; } /** diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index dba9e8a0e00..1e663eecfe1 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -24,7 +24,7 @@ class Factory implements ICacheFactory { } /** - * get a cache instance, will return null if no backend is available + * get a cache instance, or Null backend if no backend available * * @param string $prefix * @return \OC\Memcache\Cache @@ -42,7 +42,7 @@ class Factory implements ICacheFactory { } elseif (Memcached::isAvailable()) { return new Memcached($prefix); } else { - return null; + return new Null($prefix); } } diff --git a/lib/private/memcache/null.php b/lib/private/memcache/null.php new file mode 100644 index 00000000000..62cd060aaca --- /dev/null +++ b/lib/private/memcache/null.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2015 Robin McCorkell <rmccorkell@karoshi.org.uk> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Memcache; + +class Null extends Cache { + public function get($key) { + return null; + } + + public function set($key, $value, $ttl = 0) { + return true; + } + + public function hasKey($key) { + return false; + } + + public function remove($key) { + return true; + } + + public function clear($prefix = '') { + return true; + } + + static public function isAvailable() { + return true; + } +} |