diff options
author | kondou <kondou@ts.unde.re> | 2013-08-20 17:20:30 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2013-08-20 17:20:30 +0200 |
commit | f1518a54dffb4a309da3952e154b71d4bc9482f8 (patch) | |
tree | b6faeec269eb8904c5c8f42732e5466758fdeb0e /lib/autoloader.php | |
parent | 65d802329f8307cd010a306073d2d3ffd7dc7b74 (diff) | |
parent | de949b1caa4491a8016ed5e609fc781526fea54d (diff) | |
download | nextcloud-server-f1518a54dffb4a309da3952e154b71d4bc9482f8.tar.gz nextcloud-server-f1518a54dffb4a309da3952e154b71d4bc9482f8.zip |
Merge branch 'master' into clean_up_util
Conflicts:
lib/util.php
Diffstat (limited to 'lib/autoloader.php')
-rw-r--r-- | lib/autoloader.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php index 21170639092..01841f831be 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -111,15 +111,39 @@ class Autoloader { * @param string $class * @return bool */ + protected $memoryCache = null; + protected $constructingMemoryCache = true; // hack to prevent recursion public function load($class) { - $paths = $this->findClass($class); + // Does this PHP have an in-memory cache? We cache the paths there + if ($this->constructingMemoryCache && !$this->memoryCache) { + $this->constructingMemoryCache = false; + $this->memoryCache = \OC\Memcache\Factory::createLowLatency('Autoloader'); + } + if ($this->memoryCache) { + $pathsToRequire = $this->memoryCache->get($class); + if (is_array($pathsToRequire)) { + foreach ($pathsToRequire as $path) { + require_once $path; + } + return false; + } + } + // Use the normal class loading path + $paths = $this->findClass($class); if (is_array($paths)) { + $pathsToRequire = array(); foreach ($paths as $path) { if ($fullPath = stream_resolve_include_path($path)) { require_once $fullPath; + $pathsToRequire[] = $fullPath; } } + + // Save in our memory cache + if ($this->memoryCache) { + $this->memoryCache->set($class, $pathsToRequire, 60); // cache 60 sec + } } return false; } |