[Mapbender-commits] r9222 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jun 22 11:45:45 PDT 2015


Author: armin11
Date: 2015-06-22 11:45:45 -0700 (Mon, 22 Jun 2015)
New Revision: 9222

Modified:
   trunk/mapbender/http/classes/class_administration.php
Log:
Bugfix cache management

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2015-06-22 15:51:37 UTC (rev 9221)
+++ trunk/mapbender/http/classes/class_administration.php	2015-06-22 18:45:45 UTC (rev 9222)
@@ -848,7 +848,7 @@
 		return $layer_id_array;
 	}
 
- function getAllLayerByWms($wms_id){
+ 	function getAllLayerByWms($wms_id){
                 $sql = "SELECT layer_id from layer WHERE fkey_wms_id = $1 GROUP BY layer_id, layer_title ORDER BY layer_title";
                 $v = array($wms_id);
                 $t = array('i');
@@ -1565,6 +1565,118 @@
 		}
 	}
 
+	function putToStorage($filename, $content, $cacheType, $maxAge) {
+		switch ($cacheType) {
+			case "memcache":
+				$filename = md5($filename);
+				$memcache_obj = new Memcache;
+				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
+					$memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
+				} else {
+					//use standard options
+					$memcache_obj->connect('localhost', 11211);
+				}
+				//check for existence
+				$objectExists = $memcache_obj->get($filename);
+
+				if ($objectExists == false) {
+					$memcache_obj->add($filename, $content, false, $maxAge);
+					new mb_notice("add object");
+				} else {
+					$memcache_obj->replace($filename, $content, false, $maxAge);
+					new mb_notice("replace object");
+				}
+				$memcache_obj->close();
+				return true;
+			break;
+			case "memcached":
+				$filename = md5($filename);
+				$memcached_obj = new Memcached;
+				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
+					$memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
+				} else {
+					//use standard options
+					$memcached_obj->addServer('localhost', 11211);
+				}
+				new mb_notice("file stored via memcacheD");
+				
+				$memcached_obj->set($filename, $content, $maxAge);
+				//$memcached_obj->quit();
+				return true;
+			break;
+			case "cache":
+				$filename = md5($filename);
+				$cache = new Cache();
+				if ($cache->isActive) {
+					if ($cache->cachedVariableExists($filename)) {
+						$cache->cachedVariableDelete($filename);
+					}
+					return $cache->cachedVariableAdd($filename, $content ,$maxAge);
+				} else {
+					return false;
+				}
+			break;
+			case "file":
+				file_put_contents($filename, $content);
+			break;
+			default:
+				file_put_contents($filename, $content);
+			break;
+		}
+	}
+
+	function getFromStorage($filename, $cacheType) {
+		switch ($cacheType) {
+			case "memcache":
+				$filename = md5($filename);
+				$memcache_obj = new Memcache;
+				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
+					$memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
+				} else {
+					//use standard options
+					$memcache_obj->connect('localhost', 11211);
+				}
+				$content = $memcache_obj->get($filename);
+				$memcache_obj->close();
+				return $content;
+			break;
+			case "memcached":
+				$filename = md5($filename);
+				$memcached_obj = new Memcached;
+				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
+					$memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
+				} else {
+					//use standard options
+					$memcached_obj->addServer('localhost', 11211);
+				}
+				new mb_notice("content via memcacheD");
+				$content = $memcached_obj->get($filename);
+				//$memcached_obj->quit();
+				return $content;
+			break;
+			case "cache":
+				$filename = md5($filename);
+				$cache = new Cache();
+				if ($cache->isActive && $cache->cachedVariableExists($filename)) {
+					$content = $cache->cachedVariableFetch($filename);
+					return $content;
+				} else {
+					return false;
+				}
+			break;
+			case "file":
+				$content = file_get_contents($filename);
+				return $content;
+			break;
+			default:
+				$content = file_get_contents($filename);
+				return $content;
+			break;
+		}
+	}
+
+
+
 	function is_utf8_string($string) {
 	    if (is_array($string))
 	    {
@@ -1692,117 +1804,6 @@
 	 
 	 
 	 
-	function putToStorage($filename, $content, $cacheType, $maxAge) {
-		switch ($cacheType) {
-			case "memcache":
-				$filename = md5($filename);
-				$memcache_obj = new Memcache;
-				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-					$memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
-				} else {
-					//use standard options
-					$memcache_obj->connect('localhost', 11211);
-				}
-				//check for existence
-				$objectExists = $memcache_obj->get($filename);
-
-				if ($objectExists == false) {
-					$memcache_obj->add($filename, $content, false, $maxAge);
-					new mb_notice("add object");
-				} else {
-					$memcache_obj->replace($filename, $content, false, $maxAge);
-					new mb_notice("replace object");
-				}
-				$memcache_obj->close();
-				return true;
-			break;
-			case "memcached":
-				$filename = md5($filename);
-				$memcached_obj = new Memcached;
-				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-					$memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
-				} else {
-					//use standard options
-					$memcached_obj->addServer('localhost', 11211);
-				}
-				new mb_notice("file stored via memcacheD");
-				
-				$memcached_obj->set($filename, $content, $maxAge);
-				//$memcached_obj->quit();
-				return true;
-			break;
-			case "cache":
-				$filename = md5($filename);
-				$cache = new Cache();
-				if ($cache->isActive) {
-					if ($cache->cachedVariableExists($filename)) {
-						$cache->cachedVariableDelete($filename);
-					}
-					return $cache->cachedVariableAdd($filename, $content ,$maxAge);
-				} else {
-					return false;
-				}
-			break;
-			case "file":
-				file_put_contents($filename, $content);
-			break;
-			default:
-				file_put_contents($filename, $content);
-			break;
-		}
-	}
-
-	function getFromStorage($filename, $cacheType) {
-		switch ($cacheType) {
-			case "memcache":
-				$filename = md5($filename);
-				$memcache_obj = new Memcache;
-				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-					$memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
-				} else {
-					//use standard options
-					$memcache_obj->connect('localhost', 11211);
-				}
-				$content = $memcache_obj->get($filename);
-				$memcache_obj->close();
-				return $content;
-			break;
-			case "memcached":
-				$filename = md5($filename);
-				$memcached_obj = new Memcached;
-				if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-					$memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
-				} else {
-					//use standard options
-					$memcached_obj->addServer('localhost', 11211);
-				}
-				new mb_notice("content via memcacheD");
-				$content = $memcached_obj->get($filename);
-				//$memcached_obj->quit();
-				return $content;
-			break;
-			case "cache":
-				$filename = md5($filename);
-				$cache = new Cache();
-				if ($cache->isActive && $cache->cachedVariableExists($filename)) {
-					$content = $cache->cachedVariableFetch($filename);
-					return $content;
-				} else {
-					return false;
-				}
-			break;
-			case "file":
-				$content = file_get_contents($filename);
-				return $content;
-			break;
-			default:
-				$content = file_get_contents($filename);
-				return $content;
-			break;
-		}
-	}
-
-
 	 
 	 
 	 



More information about the Mapbender_commits mailing list