summaryrefslogtreecommitdiffstats
path: root/system/application/libraries/MemcacheLibrary.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-11-07 18:24:28 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-11-07 18:47:18 +0100
commitdf26ee52259cfcb66701a072266fd59fe75ef389 (patch)
tree210e39c2ec6ad12fbbe3062fa183422be0ea5a8f /system/application/libraries/MemcacheLibrary.php
parent4e058f32ff6174698709a9afdf67f4f9af60e7db (diff)
change indentaion to tabs
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application/libraries/MemcacheLibrary.php')
-rw-r--r--system/application/libraries/MemcacheLibrary.php321
1 files changed, 159 insertions, 162 deletions
diff --git a/system/application/libraries/MemcacheLibrary.php b/system/application/libraries/MemcacheLibrary.php
index 367c85078..dcc08b942 100644
--- a/system/application/libraries/MemcacheLibrary.php
+++ b/system/application/libraries/MemcacheLibrary.php
@@ -16,167 +16,164 @@
class MemcacheLibrary {
- /**
- * variable that holds memcached backend instance
- *
- * @var object
- * @access public
- */
- public $memcachedInstance;
-
- /**
- * variable that holds servers for the memcache
- *
- * @var array
- * @access public
- */
- public $servers = array();
-
-
- /**
- * main CodeIgniter instance
- *
- * @var object
- * @access public
- */
- public $CI;
-
- /**
- * constructor function for the library
- */
- public function __construct() {
-
- /* initialize memcached instance */
- if(class_exists("Memcache")) {
- $this->memcachedInstance = new Memcache();
- } else {
- throw new Exception(
- "Memcached client doesn't exists in your PHP configuration"
- );
- }
-
- /* load super CI instance */
- $this->CI =& get_instance();
-
- /* load default server info */
- $this->CI->config->load("memcache");
-
- /* connect to default server */
- if($this->CI->config->item("MEMCACHE_HOST") && $this->CI->config->item("MEMCACHE_PORT") !== false) {
- $this->addServer($this->CI->config->item("MEMCACHE_HOST"), $this->CI->config->item("MEMCACHE_PORT"));
- }
-
- }
-
- /**
- * adder function for the memcache servers
- *
- * @access public
- * @return void
- */
- public function addServer($server, $port) {
- $this->servers[] = array(
- "server" => $server,
- "port" => $port,
- );
-
- $this->memcachedInstance->addServer($server, $port);
- }
-
- /**
- * gets related key from the memcache
- *
- * @access public
- */
- public function get($key) {
- $this->logDebugMessage(sprintf("%s key requested from memcache", $key));
- return $this->memcachedInstance->get($key);
- }
-
- /**
- * sets related key to the memcache
- *
- * @access public
- */
- public function set($key, $value, $expire = null) {
- $this->logDebugMessage(
- sprintf("%s key set to memcache. (expire: %s)",$key, $expire)
- );
- return $this->memcachedInstance->set($key, $value, null, $expire);
- }
-
- /**
- * deletes related key from the memcache
- *
- * @access public
- */
- public function delete($key) {
- $this->logDebugMessage(sprintf("%s key deleted from memcache.", $key));
- return $this->memcachedInstance->delete($key);
- }
-
- /**
- * increments related key from the memcache
- *
- * @access public
- */
- public function increment($key, $offset = 1) {
- $this->logDebugMessage(sprintf("%s key incremented %s times", $key, $offset));
- return $this->memcachedInstance->increment($key, $offset);
- }
-
- /**
- * decrements related key from the memcache
- *
- * @access public
- */
- public function decrement($key, $offset = 1) {
- $this->logDebugMessage(sprintf("%s key decremented %s times", $key, $offset));
- return $this->memcachedInstance->decrement($key, $offset);
- }
-
- /**
- * gets running memcached servers.
- *
- * @access public
- * @return array
- */
- public function getRunningServers() {
- return $this->servers;
- }
-
- /**
- * array of server statistics, one entry per server.
- *
- * @access public
- * @return array
- */
- public function getStatistics() {
- return $this->memcachedInstance->getStats();
- }
-
- /**
- * Invalidates all items from the memcache.
- *
- * @access public
- * @return boolean
- */
- public function flush($delay = 0) {
- $this->logDebugMessage(sprintf("memcache flushed! (delay: %s)", $delay));
- return $this->memcachedInstance->flush($delay);
- }
-
- /**
- * logs the memcache actions to the codeigniter's main logging system.
- *
- * @access private
- */
- private function logDebugMessage($message) {
- log_message("debug", $message);
- }
+ /**
+ * variable that holds memcached backend instance
+ *
+ * @var object
+ * @access public
+ */
+ public $memcachedInstance;
+
+ /**
+ * variable that holds servers for the memcache
+ *
+ * @var array
+ * @access public
+ */
+ public $servers = array();
+
+
+ /**
+ * main CodeIgniter instance
+ *
+ * @var object
+ * @access public
+ */
+ public $CI;
+
+ /**
+ * constructor function for the library
+ */
+ public function __construct() {
+
+ /* initialize memcached instance */
+ if(class_exists("Memcache")) {
+ $this->memcachedInstance = new Memcache();
+ } else {
+ throw new Exception(
+ "Memcached client doesn't exists in your PHP configuration"
+ );
+ }
+
+ /* load super CI instance */
+ $this->CI =& get_instance();
+
+ /* load default server info */
+ $this->CI->config->load("memcache");
+
+ /* connect to default server */
+ if($this->CI->config->item("MEMCACHE_HOST") && $this->CI->config->item("MEMCACHE_PORT") !== false) {
+ $this->addServer($this->CI->config->item("MEMCACHE_HOST"), $this->CI->config->item("MEMCACHE_PORT"));
+ }
+
+ }
+
+ /**
+ * adder function for the memcache servers
+ *
+ * @access public
+ * @return void
+ */
+ public function addServer($server, $port) {
+ $this->servers[] = array(
+ "server" => $server,
+ "port" => $port,
+ );
+
+ $this->memcachedInstance->addServer($server, $port);
+ }
+
+ /**
+ * gets related key from the memcache
+ *
+ * @access public
+ */
+ public function get($key) {
+ $this->logDebugMessage(sprintf("%s key requested from memcache", $key));
+ return $this->memcachedInstance->get($key);
+ }
+
+ /**
+ * sets related key to the memcache
+ *
+ * @access public
+ */
+ public function set($key, $value, $expire = null) {
+ $this->logDebugMessage(
+ sprintf("%s key set to memcache. (expire: %s)",$key, $expire)
+ );
+ return $this->memcachedInstance->set($key, $value, null, $expire);
+ }
+
+ /**
+ * deletes related key from the memcache
+ *
+ * @access public
+ */
+ public function delete($key) {
+ $this->logDebugMessage(sprintf("%s key deleted from memcache.", $key));
+ return $this->memcachedInstance->delete($key);
+ }
+
+ /**
+ * increments related key from the memcache
+ *
+ * @access public
+ */
+ public function increment($key, $offset = 1) {
+ $this->logDebugMessage(sprintf("%s key incremented %s times", $key, $offset));
+ return $this->memcachedInstance->increment($key, $offset);
+ }
+
+ /**
+ * decrements related key from the memcache
+ *
+ * @access public
+ */
+ public function decrement($key, $offset = 1) {
+ $this->logDebugMessage(sprintf("%s key decremented %s times", $key, $offset));
+ return $this->memcachedInstance->decrement($key, $offset);
+ }
+
+ /**
+ * gets running memcached servers.
+ *
+ * @access public
+ * @return array
+ */
+ public function getRunningServers() {
+ return $this->servers;
+ }
+
+ /**
+ * array of server statistics, one entry per server.
+ *
+ * @access public
+ * @return array
+ */
+ public function getStatistics() {
+ return $this->memcachedInstance->getStats();
+ }
+
+ /**
+ * Invalidates all items from the memcache.
+ *
+ * @access public
+ * @return boolean
+ */
+ public function flush($delay = 0) {
+ $this->logDebugMessage(sprintf("memcache flushed! (delay: %s)", $delay));
+ return $this->memcachedInstance->flush($delay);
+ }
+
+ /**
+ * logs the memcache actions to the codeigniter's main logging system.
+ *
+ * @access private
+ */
+ private function logDebugMessage($message) {
+ log_message("debug", $message);
+ }
}
-
-
-
-?>
+# vim: set noet: