Adding default SVN properties svn:keywords and svn:eol-style to files added lately
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / adodb / adodb-memcache.lib.inc.php
index bc6b420..8f70935 100644 (file)
-<?php\r
-\r
-// security - hide paths\r
-if (!defined('ADODB_DIR')) die();\r
-\r
-global $ADODB_INCLUDED_MEMCACHE;\r
-$ADODB_INCLUDED_MEMCACHE = 1;\r
-\r
-/* \r
-\r
-  V4.90 8 June 2006  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.\r
-  Released under both BSD license and Lesser GPL library license. \r
-  Whenever there is any discrepancy between the two licenses, \r
-  the BSD license will take precedence. See License.txt. \r
-  Set tabs to 4 for best viewing.\r
-  \r
-  Latest version is available at http://adodb.sourceforge.net\r
-  \r
-*/\r
-\r
-       function &getmemcache($key,&$err, $timeout=0, $host, $port)\r
-       {\r
-               $false = false;\r
-               $err = false;\r
-\r
-               if (!function_exists('memcache_pconnect')) {\r
-                       $err = 'Memcache module PECL extension not found!';\r
-                       return $false;\r
-               }\r
-\r
-               $memcache = new Memcache;\r
-               if (!@$memcache->pconnect($host, $port)) {\r
-                       $err = 'Can\'t connect to memcache server on: '.$host.':'.$port;\r
-                       return $false;\r
-               }\r
-\r
-               $rs = $memcache->get($key);\r
-               if (!$rs) {\r
-                       $err = 'Item with such key doesn\'t exists on the memcached server.';\r
-                       return $false;\r
-               }\r
-\r
-               $tdiff = intval($rs->timeCreated+$timeout - time());\r
-               if ($tdiff <= 2) {\r
-                       switch($tdiff) {\r
-                               case 2: \r
-                                       if ((rand() & 15) == 0) {\r
-                                               $err = "Timeout 2";\r
-                                               return $false;\r
-                                       }\r
-                                       break;\r
-                               case 1:\r
-                                       if ((rand() & 3) == 0) {\r
-                                               $err = "Timeout 1";\r
-                                               return $false;\r
-                                       }\r
-                                       break;\r
-                               default: \r
-                                       $err = "Timeout 0";\r
-                                       return $false;\r
-                       }\r
-               }\r
-               return $rs;\r
-       }\r
-\r
-       function putmemcache($key, $rs, $host, $port, $compress, $debug=false)\r
-       {\r
-               $false = false;\r
-               $true = true;\r
-\r
-               if (!function_exists('memcache_pconnect')) {\r
-                       if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n");\r
-                       return $false;\r
-               }\r
-\r
-               $memcache = new Memcache;\r
-               if (!@$memcache->pconnect($host, $port)) {\r
-                       if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n");\r
-                       return $false;\r
-               }\r
-\r
-               $rs->timeCreated = time();\r
-               if (!$memcache->set($key, $rs, $compress, 0)) {\r
-                       if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n");\r
-                       return $false;\r
-               }\r
-               return $true;\r
-       }\r
-\r
-       function flushmemcache($key=false, $host, $port, $debug=false)\r
-       {\r
-               if (!function_exists('memcache_pconnect')) {\r
-                       if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n");\r
-                       return;\r
-               }\r
-\r
-               $memcache = new Memcache;\r
-               if (!@$memcache->pconnect($host, $port)) {\r
-                       if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n");\r
-                       return;\r
-               }\r
-\r
-               if ($key) {\r
-                       if (!$memcache->delete($key)) {\r
-                               if ($debug) ADOConnection::outp("CacheFlush: $key entery doesn't exist on memcached server!<br>\n");\r
-                       } else {\r
-                               if ($debug) ADOConnection::outp("CacheFlush: $key entery flushed from memcached server!<br>\n");\r
-                       }\r
-               } else {\r
-                       if (!$memcache->flush()) {\r
-                               if ($debug) ADOConnection::outp("CacheFlush: Failure flushing all enteries from memcached server!<br>\n");\r
-                       } else {\r
-                               if ($debug) ADOConnection::outp("CacheFlush: All enteries flushed from memcached server!<br>\n");\r
-                       }\r
-               }\r
-               return;\r
-       }\r
-?>\r
+<?php
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+global $ADODB_INCLUDED_MEMCACHE;
+$ADODB_INCLUDED_MEMCACHE = 1;
+
+/* 
+
+  V4.90 8 June 2006  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+*/
+
+       function &getmemcache($key,&$err, $timeout=0, $host, $port)
+       {
+               $false = false;
+               $err = false;
+
+               if (!function_exists('memcache_pconnect')) {
+                       $err = 'Memcache module PECL extension not found!';
+                       return $false;
+               }
+
+               $memcache = new Memcache;
+               if (!@$memcache->pconnect($host, $port)) {
+                       $err = 'Can\'t connect to memcache server on: '.$host.':'.$port;
+                       return $false;
+               }
+
+               $rs = $memcache->get($key);
+               if (!$rs) {
+                       $err = 'Item with such key doesn\'t exists on the memcached server.';
+                       return $false;
+               }
+
+               $tdiff = intval($rs->timeCreated+$timeout - time());
+               if ($tdiff <= 2) {
+                       switch($tdiff) {
+                               case 2: 
+                                       if ((rand() & 15) == 0) {
+                                               $err = "Timeout 2";
+                                               return $false;
+                                       }
+                                       break;
+                               case 1:
+                                       if ((rand() & 3) == 0) {
+                                               $err = "Timeout 1";
+                                               return $false;
+                                       }
+                                       break;
+                               default: 
+                                       $err = "Timeout 0";
+                                       return $false;
+                       }
+               }
+               return $rs;
+       }
+
+       function putmemcache($key, $rs, $host, $port, $compress, $debug=false)
+       {
+               $false = false;
+               $true = true;
+
+               if (!function_exists('memcache_pconnect')) {
+                       if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n");
+                       return $false;
+               }
+
+               $memcache = new Memcache;
+               if (!@$memcache->pconnect($host, $port)) {
+                       if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n");
+                       return $false;
+               }
+
+               $rs->timeCreated = time();
+               if (!$memcache->set($key, $rs, $compress, 0)) {
+                       if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n");
+                       return $false;
+               }
+               return $true;
+       }
+
+       function flushmemcache($key=false, $host, $port, $debug=false)
+       {
+               if (!function_exists('memcache_pconnect')) {
+                       if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n");
+                       return;
+               }
+
+               $memcache = new Memcache;
+               if (!@$memcache->pconnect($host, $port)) {
+                       if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n");
+                       return;
+               }
+
+               if ($key) {
+                       if (!$memcache->delete($key)) {
+                               if ($debug) ADOConnection::outp("CacheFlush: $key entery doesn't exist on memcached server!<br>\n");
+                       } else {
+                               if ($debug) ADOConnection::outp("CacheFlush: $key entery flushed from memcached server!<br>\n");
+                       }
+               } else {
+                       if (!$memcache->flush()) {
+                               if ($debug) ADOConnection::outp("CacheFlush: Failure flushing all enteries from memcached server!<br>\n");
+                       } else {
+                               if ($debug) ADOConnection::outp("CacheFlush: All enteries flushed from memcached server!<br>\n");
+                       }
+               }
+               return;
+       }
+?>