incubator-olio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject svn commit: r746312 - in /incubator/olio/webapp/php/trunk: classes/CacheSystem.php classes/NoCache.php public_html/index.php
Date Fri, 20 Feb 2009 18:04:44 GMT
Author: akara
Date: Fri Feb 20 18:04:44 2009
New Revision: 746312

URL: http://svn.apache.org/viewvc?rev=746312&view=rev
Log:
Addition for issue OLIO-3: Addition submitted by Damien Cooke. 
- Adding NoCache which is an option to turn off caching in the Olio PHP application. 
- Akara removed $web20config['cacheSystemIsActive'] from the config.php as added by the patch.
No additional variable should be needed. NoCache itself is already an indicator that cache
is off and there is no second stub where caching is off.

Added:
    incubator/olio/webapp/php/trunk/classes/NoCache.php
Modified:
    incubator/olio/webapp/php/trunk/classes/CacheSystem.php
    incubator/olio/webapp/php/trunk/public_html/index.php

Modified: incubator/olio/webapp/php/trunk/classes/CacheSystem.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/CacheSystem.php?rev=746312&r1=746311&r2=746312&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/CacheSystem.php (original)
+++ incubator/olio/webapp/php/trunk/classes/CacheSystem.php Fri Feb 20 18:04:44 2009
@@ -23,6 +23,11 @@
         $classname = Web20::$config['cacheSystem'];
         return new $classname;
     }
+
+    static function isCachingActive()
+    {
+        return !(Web20::$config['cacheSystem'] == 'NoCache');
+    }
     
     abstract function flush();
 

Added: incubator/olio/webapp/php/trunk/classes/NoCache.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/NoCache.php?rev=746312&view=auto
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/NoCache.php (added)
+++ incubator/olio/webapp/php/trunk/classes/NoCache.php Fri Feb 20 18:04:44 2009
@@ -0,0 +1,89 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Constructed by Damien Cooke (damien.cooke@sun.com)
+ * The purpose of this apparently empty class is to have a cache system
+ * that does no caching, but requires no code changes to turn it on or off.
+ * There are two basic ways of doing this.  1 - have a config boolean that
+ * requires a fair number of checks. 2 - have a fully featured cache system that
+ * does not comit anything to or retrieve andything from the underlying cache.
+ * What we have done is created stubs of the abstract methods from the base
+ * class so the only cost is the method invocation.
+ */
+
+class NoCache extends CacheSystem
+{ 
+	function __construct()
+    {
+        return;
+	}
+
+	function delete($key, $timeout=0)
+    {
+		return;
+	}
+
+ 	function flush()
+    {
+ 		return;
+ 	}
+
+ 	function get($key)
+    {
+ 		return null;
+    }
+
+	function set($key, $var, $compress=0, $expire)
+    {
+		return;
+	}
+
+	function add($key, $var, $compress=0, $expire=0)
+    {
+		return;
+	}
+
+	function replace($key, $var, $compress=0, $expire=0)
+    {
+		return;
+	}
+
+	function increment($key, $value=1)
+    {
+		return;
+	}
+
+	function decrement($key, $value=1)
+    {
+		return;
+	}
+
+	function needsRefresh($key)
+    {
+	    return true;
+    }
+
+
+	function doneRefresh($key, $timeToNextRefresh)
+    {
+	    return;
+	}
+}
+?>

Modified: incubator/olio/webapp/php/trunk/public_html/index.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/index.php?rev=746312&r1=746311&r2=746312&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/index.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/index.php Fri Feb 20 18:04:44 2009
@@ -103,6 +103,14 @@
     session_unregister ("currentpage");
 }
 
+/*
+ * In order to ensure that we do not loop indefinately we jimmy the $cacheType
+ * if the cache is turned off.
+ */
+if(!CacheSystem::isCachingActive())
+{
+    $cacheType = 0;
+}
 switch ($cacheType) {
     case 0: noCachePage(); break;
     case 1: contentCachePage(); break;
@@ -188,6 +196,7 @@
     global $order, $numPages, $curr_page, $prev_page, $next_page, $offset;
 
     $cache = CacheSystem::getInstance();
+
     for (;;) {
         $fillContent = $cache->get('HomeContent');
         if ($fillContent != '') {



Mime
View raw message