Remove memory cache singleton
[gitphp.git] / include / git / projectlist / ProjectListBase.class.php
blob:a/include/git/projectlist/ProjectListBase.class.php -> blob:b/include/git/projectlist/ProjectListBase.class.php
--- a/include/git/projectlist/ProjectListBase.class.php
+++ b/include/git/projectlist/ProjectListBase.class.php
@@ -80,6 +80,13 @@
 	protected $cache = null;
 
 	/**
+	 * Memory cache instance for all project
+	 *
+	 * @var GitPHP_MemoryCache
+	 */
+	protected $memoryCache = null;
+
+	/**
 	 * Constructor
 	 *
 	 * @param string $projectRoot project root
@@ -94,6 +101,8 @@
 		if (!is_dir($this->projectRoot)) {
 			throw new Exception(sprintf(__('%1$s is not a directory'), $this->projectRoot));
 		}
+
+		$this->memoryCache = new GitPHP_MemoryCache(GitPHP_Config::GetInstance()->GetValue('objectmemory', 0));
 
 		if (GitPHP_Config::GetInstance()->GetValue('objectcache', false)) {
 			$this->cache = new GitPHP_Cache();
@@ -104,6 +113,50 @@
 	}
 
 	/**
+	 * Get memory cache instance
+	 *
+	 * @access public
+	 * @return GitPHP_MemoryCache|null
+	 */
+	public function GetMemoryCache()
+	{
+		return $this->memoryCache;
+	}
+
+	/**
+	 * Set memory cache instance
+	 *
+	 * @access public
+	 * @param GitPHP_MemoryCache|null $memoryCache memory cache instance
+	 */
+	public function SetMemoryCache($memoryCache)
+	{
+		$this->memoryCache = $memoryCache;
+	}
+
+	/**
+	 * Get object cache instance
+	 *
+	 * @access public
+	 * @return GitPHP_Cache|null object cache
+	 */
+	public function GetCache()
+	{
+		return $this->cache;
+	}
+
+	/**
+	 * Set object cache instance
+	 *
+	 * @access public
+	 * @param GitPHP_Cache|null $cache object cache instance
+	 */
+	public function SetCache($cache)
+	{
+		$this->cache = $cache;
+	}
+
+	/**
 	 * Test if the projectlist contains the given project
 	 *
 	 * @return boolean true if project exists in list
@@ -172,6 +225,10 @@
 	{
 		if (!$project)
 			return;
+
+		if ($this->memoryCache) {
+			$project->GetObjectManager()->SetMemoryCache($this->memoryCache);
+		}
 
 		if ($this->cache) {
 			$project->GetObjectManager()->SetCache($this->cache);

comments