Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added caching of Object dependencies

  • Loading branch information...
commit 70a77c48d0470983794f21933479007cd41b57ea 1 parent 3930414
predakanga authored
Showing with 11 additions and 2 deletions.
  1. +1 −1  src/Object.php
  2. +10 −1 src/ObjectContainer.php
2  src/Object.php
View
@@ -97,7 +97,7 @@ protected function determineObjects() {
}
// And store them
- $this->container->dependencies[$classname] = $deps;
+ $this->container->setDependencies($classname, $deps);
}
return $this->container->dependencies[$classname];
11 src/ObjectContainer.php
View
@@ -104,6 +104,7 @@ public function updateCache() {
$cacheObj = array('registrations' => $this->registrations,
'instancedTypes' => $this->instancedTypes,
'classMap' => $this->classMap,
+ 'dependencies' => $this->dependencies,
'mtime' => $this->get("Core")->getMtime());
file_put_contents($filename, yaml_emit($cacheObj));
}
@@ -117,16 +118,18 @@ protected function cachedInit() {
$origReg = $this->registrations;
$origInstTypes = $this->instancedTypes;
$origClassMap = $this->classMap;
+ $origDeps = $this->dependencies;
@$this->registrations = $cache['registrations'];
@$this->instancedTypes = $cache['instancedTypes'];
@$this->classMap = $cache['classMap'];
+ @$this->dependencies = $cache['dependencies'];
@$mtime = $cache['mtime'];
if(!$mtime) {
$mtime = 0;
}
$cacheSucceeded = true;
- if(!$this->registrations || !$this->instancedTypes || !$this->classMap) {
+ if(!$this->registrations || !$this->instancedTypes || !$this->classMap || !$this->dependencies) {
$cacheSucceeded = false;
} else {
// TODO: Add setting to only check mtimes sometimes
@@ -143,6 +146,7 @@ protected function cachedInit() {
$this->registrations = $origReg;
$this->instancedTypes = $origInstTypes;
$this->classMap = $origClassMap;
+ $this->dependencies = $origDeps;
return false;
}
}
@@ -561,6 +565,11 @@ public function setClassMap($classMap) {
$this->classMap += $classMap;
}
+ public function setDependencies($class, $deps) {
+ $this->dependencies[$class] = $deps;
+ $this->updateCache();
+ }
+
public function __sleep() {
return array('registrations', 'instancedTypes', 'classmap');
}
Please sign in to comment.
Something went wrong with that request. Please try again.